This file contains hidden or 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.Objects; | |
| public class Pizza implements Delivarable { | |
| private DelivarableStatus status = DelivarableStatus.IN_PROGRESS; | |
| private PizzaDeliveryStrategy strategy; | |
| public Pizza(PizzaDeliveryStrategy strategy){ |
This file contains hidden or 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.Objects; | |
| public class Pizza implements Delivarable { | |
| public enum PizzaStatus { | |
| IN_PROGRESS, | |
| READY, | |
| DELIVERED; | |
| } | |
| private PizzaStatus pizzaStatus = PizzaStatus.IN_PROGRESS; |
This file contains hidden or 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
| public enum PizzaDeliveryStrategy implements DeliveryStrategy<Pizza> { | |
| EXPRESS { | |
| @Override | |
| public void deliver(Pizza pz) { | |
| System.out.println("Pizza will be delivered in express mode"); | |
| } | |
| }, | |
| NORMAL { | |
| @Override | |
| public void deliver(Pizza pz) { |
This file contains hidden or 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
| public interface Deliverable { | |
| public void deliver(); | |
| default public isDeliverable(){ | |
| return true; | |
| } | |
| public enum DeliverableStatus { | |
| IN_PROGRESS, | |
| READY, |
This file contains hidden or 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
| public enum Planet { | |
| MERCURY (3.303e+23, 2.4397e6), | |
| VENUS (4.869e+24, 6.0518e6), | |
| EARTH (5.976e+24, 6.37814e6), | |
| MARS (6.421e+23, 3.3972e6), | |
| JUPITER (1.9e+27, 7.1492e7), | |
| SATURN (5.688e+26, 6.0268e7), | |
| URANUS (8.686e+25, 2.5559e7), | |
| NEPTUNE (1.024e+26, 2.4746e7), | |
| PLUTO (1.27e+22, 1.137e6), |
This file contains hidden or 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
| public enum Planet { | |
| MERCURY (3.303e+23, 2.4397e6), | |
| VENUS (4.869e+24, 6.0518e6), | |
| EARTH (5.976e+24, 6.37814e6), | |
| MARS (6.421e+23, 3.3972e6), | |
| JUPITER (1.9e+27, 7.1492e7), | |
| SATURN (5.688e+26, 6.0268e7), | |
| URANUS (8.686e+25, 2.5559e7), | |
| NEPTUNE (1.024e+26, 2.4746e7), | |
| PLUTO (1.27e+22, 1.137e6); |
This file contains hidden or 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
| public enum Operation { | |
| PLUS, MINUS, TIMES, DIVIDE; | |
| // Do arithmetic op represented by this constant | |
| public double eval(double x, double y){ | |
| switch(this) { | |
| case PLUS: return x + y; | |
| case MINUS: return x - y; | |
| case TIMES: return x * y; | |
| case DIVIDE: return x / y; |
This file contains hidden or 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
| public enum Operation { | |
| PLUS { double eval(double x, double y) { return x + y; } }, | |
| MINUS { double eval(double x, double y) { return x - y; } }, | |
| TIMES { double eval(double x, double y) { return x * y; } }, | |
| DIVIDE { double eval(double x, double y) { return x / y; } }; | |
| // Do arithmetic op represented by this constant | |
| public abstract double eval(double x, double y); | |
| } |
This file contains hidden or 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
| public class MyClass { | |
| private static MyClass myClass = new MyClass(); | |
| private static MyClass myClass2 = new MyClass(); | |
| public MyClass() { | |
| System.out.println(myClass); | |
| System.out.println(myClass2); | |
| } | |
| public static void main(String[] args) { |
This file contains hidden or 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
| stdlogging.initStream(errLogger, adapter_cls='alexber.utils.stdlogging.StreamToLogger') |