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 Person { | |
public String getMiddleName(); | |
} |
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 Shape { | |
double perimeter(); | |
double area(); | |
} |
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 Rectangle implements Shape { | |
double x, y; | |
public double perimeter() { | |
return (x + y) * 2; | |
} | |
public double area() { | |
return x * y; | |
} |
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 Circle implements Shape { | |
double radius; | |
public double perimeter() { | |
return 2 * PI * radius; | |
} | |
public double area() { | |
return PI * radius * radius; | |
} |
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 Parallelogram implements Shape { } |
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 Parallelogram implements Shape { | |
public double perimeter() { | |
return 0.; | |
} | |
public double area() { | |
return 0.; | |
} | |
} |
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 Parallelogram implements Shape { | |
double base, height, side; | |
public double perimeter() { | |
return 2 * (base + side); | |
} | |
public double area() { | |
return base * height; | |
} |
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 Shape { | |
double perimeter(); | |
double area(); | |
double diameter(); | |
} |
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 Rectangle implements Shape { | |
double x, y; | |
/* ... */ | |
public double diameter() { | |
return Math.sqrt(x * x + y * y); | |
} | |
} |
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 Circle implements Shape { | |
double radius; | |
/* ... */ | |
public double diameter() { | |
return 2 * radius; | |
} | |
} |
OlderNewer