public statie void main (String args()){ Shape sl - new Cirele (5.5, "red", false): // Upcast System.out.printin (al) : System.out.println (sl.getArea ()): System.out.printin(sl.getPerimeter 0): System.out.println(sl.getcolor ()): System.out.-printin(al.isFilled ()): System.out.printin(sl.getRadius (0): <> Shape #color:String - "red" filled:Boolean - true Shape() +Shape(color:String,filled:boolean) getColor ():String +setColor(color:String):void +isFilled(): boolean +setFilled(filled:boolean):void +abstract getArea():double +abstract getPerimeter():double +tostring():String • denotes protected access Circle el - (Circle)si: // Downcast System.out.printin (el); System.out.println (cl.getArea ()): System.out.printin (el.getPerimeter ()): System.out.println (el.getcolor ()): System.out.printin (el.isFilled ()): System.out.printin (el.getRadius ()): "Shape[color-?, filled-?]" 4 extends Shape s2 - new Shape (): Shape s3 - new Rectangle (1.0, 2.0, "red", false): System.out.printin (s3) ; System.out.printin (s3.getArea ()): System.out.printin(s3.getPerimeter ()): System.out.-printin(a3. getcolor ()): System.out.printin (s3.getlength ()): Circle Rectangle Bradius:double - 1.0 +Circle() +Circle(radius:double) +Circle(radius:double, color:String, filled:boolean) +getRadius ():double +setRadius(radius:double): void +getArea()i double +getPerimeter(): double +tostring():String idth:double - 1.0 length:double - 1.e +Rectangle() +Rectangle(width:double, length:double) +Rectangle(width:double, length:double, color:String, filled:boolean) +getwidth(): double +setwidth(width:double):void +getLength(): double +setlength(legnth:double):void +getArea (): double +getPerimeter(): double **tostring():String Rectangle rl1 - (Rectangle) s3; System.out.-printin(rl) : System.out.printin (rl.getArea ()); System.out.printin(rl.getColor ()): System.out.printin(rl.getlength ()): Shape s4 - new Square (6.6); System.out.-printin (s4) : System.out.printin(s4.getArea ()); System.out.printin (s4.getcolor ()): System.out.println (s4.getside ()); "Circle[Shape[color-?, filled-?],radius-?] Rectangle r2 - (Rectangle)s4; System.out.printin(r2) : System.out.println(r2.getArea ()); System.out.printin(r2.getcolor ()): System.out.println(r2.getside ()): System.out.printin (r2.getlength ()): "Rectangle[Shape[color-?, filled-?],width-?,length-?]" Square +Square() +Square(side:double) +Square(side:double,color:String, filled:boolean) +getSide():double +setSide(side:double):void +setlidth(side: double): void +setlength(side:double):void stostring():String Square sqi - (Square) r2; System.out.printin (aql): System.out.printin (sql.getArea ()): System.out.-printin (aql.getcolor ()) : System.out.printin (sql.getside ()): System.out.printin (sql.getLength ()): "Square[Rectangle[Shape[color-?, filled-?],width-2,length-?]]"

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

In the java 

5. Write a java program as shown in the below class diagram then write the next main method and make your notes
Page | 15
JAVA - Object Oriented Programming-1
KKU-CS-113 / 222-CSM
LAB
Manual
public static void main (String args(])(
Shape sl - new Circle (5.5, "red", false); // Upcast
System.out.printin (al):
System.out.printin (sl.getArea () );
System.out.printin (sl.getPerimeter ()) :
System.out.printin (sl.getcolor ()):
System.out.printin (al.isFilled ()):
System.out.println (s1.getRadius ()):
<<abstract>> Shape
#color:String- "red"
filled:Boolean true
# denotes protected access
Shape()
+Shape(color:String, filled:boolean)
+getColor():String
+setColor(color:String):void
+isfilled(): boolean
+setFilled(filled:boolean):void
+abstract getArea():double
+abstract getPerimeter():double
+tostring():String •-
Circle cl - (Circle) si; // Downcast
System.out.printin (cl);
System.out.printin (cl.getArea () );
System.out.printin (cl.getPerimeter 0):
System.out.printin (cl.getcolor ()):
System.out.println(cl.isFilled ()):
System.out.printin(cl.getRadius ());
"Shape[color-?, filled-?]"
4 extends
Shape s2 - new Shape ():
Shape s3 - new Rectangle (1.0, 2.0, "red", false);
System.out.println (s3);
System.out.printin (s3.getArea ());
System.out.printin (s3.getPerimeter ()) :
System.out.printin (a3.getColor ()):
System.out.printin (s3.getLength ());
Circle
Rectangle
idth:double - 1.0
#length:double - 1.0
+Rectangle()
+Rectangle(width:double, length:double)
+Rectangle(width:double,length:double,
color:String, filled:boolean)
+getwidth():double
+setwidth(width:double):void
+getlength(): double
+setlength(legnth:double):void
+getArea(): double
+getPerimeter(): double
*+tostring():String
#radius:double - 1.0
+Circle()
+Circle(radius:double)
+Circle(radius:double,
color:String, filled:boolean)
+getRadius (): double
+setRadius (radius:double): void
+getArea()i double
+getPerimeter(): double
+tostring():String
Rectangle rl - (Rectangle) s3;
System.out.printin (rl);
System.out.printin (rl.getArea ());
System.out.printin (rl.getcolor ()):
System.out.println (rl.getLength ()):
Shape s4 - new Square (6.6):
System.out.printin(s4);
System.out.println (s4.getArea ());
System.out.printin (s4.getcolor ()):
System.out.println (a4.getside ()):
"Circle[Shape[color-?,
filled-?],radius-?]"
Rectangle r2 - (Rectangle)s4;
System.out.printin (r2) :
System.out.println (r2.getArea ());
System.out.printin (r2.getcolor ()):
System.out.printin (r2.getside ()):
System.out.println(r2.getlength ()) :
"Rectangle[Shape[color-?,
filled-?],width-?,length-?]"
Square
+Square()
+Square(side:double)
+Square(side:double, color:String,
filled:boolean)
+getSide(): double
+setSide(side:double):void
+setlidth(side: double): void
+setlength(side: double):void
tostring() :String
Square sql - (Square) r2;
System.out.printin (sql):
System.out.printin (sql.getArea ()):
System.out.printin (sql.getcolor ());
System.out.printin (sql.getside ()):
System.out.printin (sqi.getLength ()):
"Square[Rectangle[Shape[color-?,
filled-?],width-?,length-?]]"
Transcribed Image Text:5. Write a java program as shown in the below class diagram then write the next main method and make your notes Page | 15 JAVA - Object Oriented Programming-1 KKU-CS-113 / 222-CSM LAB Manual public static void main (String args(])( Shape sl - new Circle (5.5, "red", false); // Upcast System.out.printin (al): System.out.printin (sl.getArea () ); System.out.printin (sl.getPerimeter ()) : System.out.printin (sl.getcolor ()): System.out.printin (al.isFilled ()): System.out.println (s1.getRadius ()): <<abstract>> Shape #color:String- "red" filled:Boolean true # denotes protected access Shape() +Shape(color:String, filled:boolean) +getColor():String +setColor(color:String):void +isfilled(): boolean +setFilled(filled:boolean):void +abstract getArea():double +abstract getPerimeter():double +tostring():String •- Circle cl - (Circle) si; // Downcast System.out.printin (cl); System.out.printin (cl.getArea () ); System.out.printin (cl.getPerimeter 0): System.out.printin (cl.getcolor ()): System.out.println(cl.isFilled ()): System.out.printin(cl.getRadius ()); "Shape[color-?, filled-?]" 4 extends Shape s2 - new Shape (): Shape s3 - new Rectangle (1.0, 2.0, "red", false); System.out.println (s3); System.out.printin (s3.getArea ()); System.out.printin (s3.getPerimeter ()) : System.out.printin (a3.getColor ()): System.out.printin (s3.getLength ()); Circle Rectangle idth:double - 1.0 #length:double - 1.0 +Rectangle() +Rectangle(width:double, length:double) +Rectangle(width:double,length:double, color:String, filled:boolean) +getwidth():double +setwidth(width:double):void +getlength(): double +setlength(legnth:double):void +getArea(): double +getPerimeter(): double *+tostring():String #radius:double - 1.0 +Circle() +Circle(radius:double) +Circle(radius:double, color:String, filled:boolean) +getRadius (): double +setRadius (radius:double): void +getArea()i double +getPerimeter(): double +tostring():String Rectangle rl - (Rectangle) s3; System.out.printin (rl); System.out.printin (rl.getArea ()); System.out.printin (rl.getcolor ()): System.out.println (rl.getLength ()): Shape s4 - new Square (6.6): System.out.printin(s4); System.out.println (s4.getArea ()); System.out.printin (s4.getcolor ()): System.out.println (a4.getside ()): "Circle[Shape[color-?, filled-?],radius-?]" Rectangle r2 - (Rectangle)s4; System.out.printin (r2) : System.out.println (r2.getArea ()); System.out.printin (r2.getcolor ()): System.out.printin (r2.getside ()): System.out.println(r2.getlength ()) : "Rectangle[Shape[color-?, filled-?],width-?,length-?]" Square +Square() +Square(side:double) +Square(side:double, color:String, filled:boolean) +getSide(): double +setSide(side:double):void +setlidth(side: double): void +setlength(side: double):void tostring() :String Square sql - (Square) r2; System.out.printin (sql): System.out.printin (sql.getArea ()): System.out.printin (sql.getcolor ()); System.out.printin (sql.getside ()): System.out.printin (sqi.getLength ()): "Square[Rectangle[Shape[color-?, filled-?],width-?,length-?]]"
Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education