Skip to content

Instantly share code, notes, and snippets.

View BerkeSoysal's full-sized avatar
🦍
Focusing

Berke Soysal BerkeSoysal

🦍
Focusing
View GitHub Profile
public class Base64Hasher implements PasswordHasher, Decryptable
{
@Override
public String hashPassword(String password)
{
return "hashed with base64";
}
@Override
public String decodePasswordFromHash(String hash)
public interface Decryptable
{
String decodePasswordFromHash(String hash);
}
public interface PasswordHasher
{
String hashPassword(String password);
String decodePasswordFromHash(String hash);
}
public class Base64Hasher implements PasswordHasher
{
@Override
public String hashPassword(String password)
{
return "hashed with 64";
}
}
public String hashPassword(String password, HashingType hashingType)
{
if(HashingType.BASE64.equals(hashingType))
{
hashedPassword="hashed with Base64";
}
else if(HashingType.MD5.equals(hashingType))
{
hashedPassword="hashed with MD5";
}
public class PasswordHasher
{
public String hashAndSavePassword(String password)
{
hashPassword();
savePassword();
}
public void hashPassword()
{
public class Main {
public static void main(String[] args) {
ShipmentParameters shipmentParameters = new ShipmentParameters();
shipmentParameters.setSameCity(false);
shipmentParameters.setDistance(40);
shipmentParameters.setWeight(1);
CargoFirm safeAndQuick = new SafeAndQuick();
public class FastDeliveryByDistance implements FastDeliveryBehavior
{
private static final int distanceFor1Day = 50;
@Override
public void calculateDaysForDelivery(ShipmentParameters shipmentParameters)
{
if(shipmentParameters.distance > distanceFor1Day)
{
System.out.println("Will be delivered in 2 Days");
public class FastDeliveryByCity implements FastDeliveryBehavior
{
@Override
public void calculateDaysForDelivery(ShipmentParameters shipmentParameters)
{
if(shipmentParameters.isSameCity)
{
System.out.println("Will be delivered in 1 Days");
}
else
public class Main {
public static void main(String[] args) {
ShipmentParameters shipmentParameters = new ShipmentParameters();
shipmentParameters.isSameCity = false;
shipmentParameters.distance = 70;
shipmentParameters.weight = 1;
CargoFirm safeAndQuick = new SafeAndQuick();
safeAndQuick.createShipment();