Skip to content

Commit dc4a79b

Browse files
authored
Update design_patterns.txt
1 parent b48e148 commit dc4a79b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

design_patterns.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
11
https://ideone.com/pReC4E
2+
import java.util.*;
3+
import java.io.*;
4+
5+
interface Shape {
6+
7+
void takeInput();
8+
void draw();
9+
10+
}
11+
12+
class Circle implements Shape {
13+
14+
private int c_x, c_y, r;
15+
16+
void takeInput(){
17+
Scanner sc = new Scanner(System.in);
18+
c_x = sc.nextInt(); c_y = sc.nextInt(); r = sc.nextInt();
19+
}
20+
21+
void draw(){
22+
System.out.println(this);
23+
}
24+
25+
@Override
26+
public toString(){
27+
return "x : " + c_x + " y : " + c_y + " r : " + r;
28+
}
29+
30+
}
31+
32+
class Rectangle implements Shape{
33+
34+
private int w, h;
35+
36+
void draw(){
37+
System.out.println(this);
38+
}
39+
40+
41+
42+
@Override
43+
public toString(){
44+
return "w : " + w + " h : " + h;
45+
}
46+
47+
}

0 commit comments

Comments
 (0)