File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ abstract class Shape {
2
+ abstract void draw ();
3
+ public void paint (){
4
+ System .out .println ("rainbow..." );
5
+ }
6
+ }
7
+ class Rectangle extends Shape {
8
+ public void draw (){
9
+ System .out .println ("Draw a rectangle..." );
10
+ }
11
+ }
12
+ class Circle extends Shape {
13
+ public void draw (){
14
+ System .out .println ("Draw a circle..." );
15
+ }
16
+ }
17
+ class AbstractionDemo1 {
18
+ public static void main (String [] args ){
19
+ Shape shape = new Rectangle ();
20
+ shape .draw ();
21
+ shape .paint ();
22
+ shape = new Circle ();
23
+ shape .draw ();
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ interface Shape {
2
+ void draw ();
3
+ public static void paint (){
4
+ System .out .println ("rainbow..." );
5
+ }
6
+ }
7
+ class Rectangle implements Shape {
8
+ public void draw (){
9
+ System .out .println ("Draw a rectangle..." );
10
+ }
11
+ }
12
+ class Circle implements Shape {
13
+ public void draw (){
14
+ System .out .println ("Draw a circle..." );
15
+ }
16
+ }
17
+ class AbstractionDemo2 {
18
+ public static void main (String [] args ){
19
+ Shape shape = new Rectangle ();
20
+ shape .draw ();
21
+ Shape .paint ();
22
+ shape = new Circle ();
23
+ shape .draw ();
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments