This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package application; | |
/* ... */ | |
// Application level is the holder of primary drivers | |
// This is actually the specific implementation of the application server | |
// (SparkJava in this case) | |
public class Emapp implements Runnable { | |
private final Mapper mapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reads only valid amount from standard output and returns | |
* it to the caller. | |
* | |
* @param prompt to be shown to the user to mark where to input | |
* @param min amount allowed | |
* @param max amount allowed | |
* @return the valid amount | |
*/ | |
public BigDecimal inputBigDecimalValue(String prompt, BigDecimal min, BigDecimal max) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gk; | |
import static java.math.BigDecimal.ZERO; | |
import java.math.BigDecimal; | |
import java.util.Scanner; | |
public class AmountParser { | |
Scanner sc = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn total_price(&self, shopping_list: &[&str]) -> Option<f32> { | |
let mut total = 0.0; | |
for item in shopping_list { | |
if self.price(item) == None { | |
return None; | |
} | |
total += self.price(item).unwrap(); | |
} | |
Some(total) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.io.IOException; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Optional; | |
public class SecureMessage { | |
private final String key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com/sun/imageio/plugins/png/PNGImageReader.java: break loop; | |
com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java: break find; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_1; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_2; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_3; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_4; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_5; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_6; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_7; | |
com/sun/jmx/snmp/IPAcl/Parser.java: break label_8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yay! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class FizzBuzz { | |
public static String compute(Integer number) { | |
return Arrays.stream(Multipliers.values()) | |
.filter(m -> (number % m.multiple == 0)) | |
.map(Enum::name) | |
.reduce((s, r) -> s + r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CurrentUser extends User { | |
public String who() { | |
return "who - CurrentUser class!"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
class VarianceTest < Test::Unit::TestCase | |
def test_it_should_compute_the_average_out_of_an_array | |
assert_equal(50, [40, 30, 50, 80].average) | |
end | |
def test_it_should_compute_variance_out_of_an_array | |
assert_equal(350, [40, 30, 50, 80].variance) |
NewerOlder