Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Create a Shape class. The class has two String fields: the name and the size. It has a method printShapelnfo, which simply prints
1. Create a Shape class. The class has two String fields: the name and the size. It has a method printShapelnfo, which simply prints out the value of the name and the size field of a Shape object. It also has the methods printShapeName and printShapeSize, which prints the name and the size of the object, respectively. Using inheritance, create another class Square with the same fields and methods as those of Shape class. It has two additional integer fields: length and width. The methods printShapeLength and printShapeWidth that prints the object's length and width are also included in this class. You also need to override the printshapelnfo to also print out additional fields in the subclasses. Create a class with a main method to test out your classes. *Hint: The Square class is a subclass of the Shape class. 2. Create a Class Diagram for your classes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
1 Sample Output 2 Anima...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started