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 Assignee | |
abstract class Assignee {} | |
// Interface Dev for Developer tasks | |
interface Dev { void code(); } | |
// Interface QA for Test tasks | |
interface QA { void test(); } | |
// Developer is an Assingee |
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
// Interface Tasks | |
interface Tasks { | |
void code(); | |
void test(); | |
} | |
// Class Assignee | |
abstract class Assignee implements Tasks {} | |
// Developer is an Assingee |
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
// Enforce fossil cars to have method to return mileage | |
interface Refuelables { float getMileage(); } | |
// Car has mileage | |
abstract class Car { abstract float calculateRange(); } | |
// Fossil car is a car | |
abstract class FossilCar extends Car { float fuel; abstract float getMileage(); } | |
// Petrol car is a fossil car |
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
// Enforce cars to have method to return mileage | |
interface Refuelables { | |
float getMileage(); | |
} | |
// Car has mileage | |
abstract class Car implements Refuelables { | |
float fuel; | |
abstract float calculateRange(); | |
} |
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.ArrayList; | |
import java.util.List; | |
class Item { | |
private final String type; | |
private final double price; | |
private DiscountStrategy discountStrategy; | |
public Item(String type, double price, DiscountStrategy discountStrategy) { | |
this.type = type; |