-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataHiding.java
More file actions
50 lines (50 loc) · 938 Bytes
/
dataHiding.java
File metadata and controls
50 lines (50 loc) · 938 Bytes
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
class Rectangle
{
private double length;
private double breadth;
public double getlength()
{
return length;
}
public double getbreadth()
{
return breadth;
}
public void setlength(double l)
{
length =l;
}
public void setbreadth(double b)
{
breadth = b;
}
public double area()
{
return length * breadth;
}
public double perimeter()
{
return 2*(length + breadth);
}
public boolean isSquare()
{
if(length == breadth)
return true;
else
return false;
}
}
class Test
{
public static void main(String args[])
{
Rectangle r = new Rectangle();
r.setlength(10);
r.setbreadth(5);
System.out.println("Area of a rectangle : " + r.area());
System.out.println("Perimeter of a rectangle : " + r.perimeter());
System.out.println("Is it a square : " + r.isSquare());
System.out.println("Displaying length : " + r.getlength());
System.out.println("Displaying Breadth : " + r.getbreadth());
}
}