Created
January 10, 2022 17:49
-
-
Save meowpunch/52440fa59072c44e3dd6ccb60241f14e to your computer and use it in GitHub Desktop.
Polymorphic Shape, Chapter 6: Objects and Data Structures, Clean Code, Robert C Martin
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 implements Shape { | |
private Point topLeft; | |
private double side; | |
public double area() { | |
return side * side; | |
} | |
} | |
public class Rectangle implements Shape { | |
private Point topLeft; | |
private double height; | |
private double width; | |
public double area() { | |
return height * width; | |
} | |
} | |
public class Circle implements Shape { | |
private Point center; | |
private double radius; | |
public final double PI = 3.141592653589793; | |
public double area() { | |
return PI * radius * radius; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment