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 Pizza{ | |
void cook(); | |
String getTopping(); | |
} | |
//======= | |
class PepperoniPizza implements Pizza{ | |
String topping; | |
void cook() { | |
System.out.println("Cooking pepperoni pizza"); | |
} |
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
abstract class Pizza { | |
String topping; | |
String getTopping() { | |
return this.topping; | |
} | |
abstract void cook(); | |
} | |
// =========== | |
class PepperoniPizza extends Pizza { | |
void cook() { |
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
public class HealthInsuranceCustomerProfile implements CustomerProfile { | |
@Override | |
public boolean isLoyalCustomer() { | |
return true; | |
} | |
} |
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
public class HealthInsuranceCustomerProfile { | |
public boolean isLoyalCustomer() { | |
return true; | |
} | |
} |
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
public class HealthInsuranceCustomerProfile { | |
public boolean isLoyalCustomer() { | |
return true; | |
} | |
} |
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
public class Student { | |
private String studentId; | |
private String address; | |
private Date studentDayOfBirth; | |
public void save() { | |
new StudentRepository.save(this); | |
} | |
public String getStudentId() { |
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
public class Student { | |
private String studentId; | |
private String address; | |
private Date studentDayOfBirth; | |
public void save() { | |
String objectStr = MyUtils.serializeIntoAString(this); | |
Connection connection = null; | |
Statement statement = null; | |
try { |
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
public class Square { | |
private int side = 5; | |
public int getArea() { | |
return side * side; | |
} | |
public int getPerimeter() { | |
return side * 4; |
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
public class Square { | |
private int side = 5; | |
public int getArea() { | |
return side * side; | |
} | |
public int getPerimeter() { | |
return side * 4; |
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
public class Square { | |
private int side = 5; | |
public int getArea() { | |
return side * side; | |
} | |
public int getPerimeter() { | |
return side * 4; |
NewerOlder