-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoops_practice_7.java
55 lines (52 loc) · 1.11 KB
/
oops_practice_7.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.company;
class Rectangle7
{
int length=10;
int width=30;
public int area()
{
return length*width;
}
}
class Square7 extends Rectangle7
{
int side=10;
public int area()
{
return side*side;
}
}
class Circle7 extends Square7
{
int radius=10;
public int area()
{
return (int) (Math.PI*radius*radius);
}
}
class Cylinder7 extends Circle7
{
int height=10;
public int perimeter()
{
return (int) (2*Math.PI*radius*height);
}
}
class Sphere7 extends Circle7
{
public int area()
{
return (int) (4*Math.PI*radius*radius);
}
}
public class oops_practice_7 {
public static void main(String[] args) {
/*
*** WRITE THIS CODE IN NOTEPAD ***
You have to create a package named com.company.shape
This package should have individual classes for Rectangle, Square, Circle, Cylinder, Sphere
These classes should use inheritance to properly manage the code!
Include methods like volume, surface area and getters/setters for dimensions
*/
}
}