Problem: Develop the ‘Shape’ application such that:
· ‘Rectangle’, ‘Ellipse’, and ‘Triangle’ classes inherit from the ‘Shape’ class.
· Develop the ‘Square’ and ‘Circle’ class where ‘Square’ inherits from ‘Rectangle’ and ‘Circle’ inherits from ‘Ellipse’. ‘Triangle’ has no derived class.
· For each class, implement the overridden methods ‘draw’, ‘move’, and ‘erase’. Each method should only have an output statement such as “Rectangle – draw method” that will be displayed when the method is invoked.
· Implement the default constructors for each class with a corresponding message to be displayed when invoked. No initializations are required; that is, the output message will be the only executable statement in the constructors.
· Do not implement any other methods for these classes ( i.e., ‘toString’, ‘equals’, getters and setters ).
· Implement a ‘ShapeTest’ class which will instantiate an object of each class.
· Exercise each of the ‘draw’, ‘move’, and ‘erase’ methods of each class
· Remember to make sure that there is only a single class per file.
Answer:
ShapeTest.java
public class ShapeTest
{
public static void main(String args[])
{
Square s =new Square();
s.draw();
s.erase();
s.move();
Circle c=new Circle();
c.draw();
c.erase();
c.move();
Traingle t=new Traingle();
t.draw();
t.erase();
t.move();
}}
Shape.java
class Shape{
protected String name;
protected String phoneNumber;
Shape()
{
System.out.println("shape class constructor");
}
public void draw()
{
System.out.println("shape draw mwthod");
}
public void move()
{
System.out.println("shape move mwthod");
}
public void erase()
{
System.out.println("shape erase mwthod");
}
}
Rectangle.java
class Rectangle extends Shape
{
Rectangle()
{
System.out.println("Rectangle class constructor");
}
public void draw()
{
System.out.println("rectangle draw mwthod");
}
public void move()
{
System.out.println("rectangle move mwthod");
}
public void erase()
{
System.out.println("rectangle erase mwthod");
}
}
Traingle.java
class Traingle extends Shape
{
Traingle()
{
System.out.println("Traingle class constructor");
}
public void draw()
{
System.out.println("traingle draw mwthod");
}
public void move()
{
System.out.println("traingle move mwthod");
}
public void erase()
{
System.out.println("traingle erase mwthod");
}
}
Ellipse.java
class Ellipse extends Shape
{
Ellipse()
{
System.out.println("Ellipse class constructor");
}
public void draw()
{
System.out.println("ellipse draw mwthod");
}
public void move()
{
System.out.println("ellipse move mwthod");
}
public void erase()
{
System.out.println("ellipse erase mwthod");
}
}
Square.java
class Square extends Rectangle
{
Square()
{
System.out.println("Square class constructor");
}
public void draw()
{
System.out.println("square draw mwthod");
}
public void move()
{
System.out.println("square move mwthod");
}
public void erase()
{
System.out.println("square erase mwthod");
}
}
Circle.java
class Circle extends Ellipse
{
Circle()
{
System.out.println("Circle class constructor");
}
public void draw()
{
System.out.println("circle draw mwthod");
}
public void move()
{
System.out.println("circle move mwthod");
}
public void erase()
{
System.out.println("circle erase mwthod");
}
}

Problem: Develop the ‘Shape’ application such that: · ‘Rectangle’, ‘Ellipse’, and ‘Triangle’ classes inherit from the...
Language is JAVA.
Clarification for the Shape class (highlighted):
The following requirements specify what fields you are expected
to implement in your Shape class;
- A private String color that specifies the color of the
shape
- A private boolean filled that specifies whether the shape is
filled
- A private date (java.util.date) field dateCreated that
specifies the date the shape was created Your Shape class will
provide the following constructors;
- A two-arg constructor that creates a shape
with...
c++
6. Define classes shape, and classes circle and square, which inherit from shape. At the bottom of the page is a sample program using these classes, followed by its output. (a) Class shape has abstract virtual constant functions area and border which do not take arguments and which return double. It has a virtual constant function where which has no arguments and returns its lo- cation. It has a private field of type location and a ctor which accepts...
in C++ use Inheritance for the following Shape Circle Sphere Cylinder Rectangle Square Cube You must define one class for each shape. And, use public inheritance when deriving from base classes. Circle int r; void area(); void perimeter(); void volume(); //No volume for circle Sphere int r; void area();//Sphere surface area= 4 × pi × radius2 void perimeter(); //No perimeter for Sphere void volume();//Sphere volume= 4/3 × pi × radius2 Cylinder int r, height; void area();// Cylinder surface area=perimeter of...
java language
Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...
I need help with a java error Question: Consider a graphics system that has classes for various figures—say, rectangles, boxes, triangles, circles, and so on. For example, a rectangle might have data members’ height, width, and center point, while a box and circle might have only a center point and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. You are to implement such a system. The class Figure is...
I need help with a java error Question: Consider a graphics system that has classes for various figures—say, rectangles, boxes, triangles, circles, and so on. For example, a rectangle might have data members’ height, width, and center point, while a box and circle might have only a center point and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. You are to implement such a system. The class Figure is...
A general shape class is shown below. Shape has a dimension. It also defines constructors, getters, setters and a toString method. class Shape{ int dimension; public Shape(){} public Shape(int newDimension){ dimension = newDimension; } public int getDimension(){ return dimension; } public void setDimension(int newDimension){ dimension = newDimension; } public String toString(){ return "Shape has dimension "+dimension; } } a. Define classes Circle and Square, which inherit from Shape class. b. Both classes must have two constructors similar to Shape class....
.Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...
Define an abstract base class SHAPE that includes protected data members for the (x,y) position of a shape, a public method to move a shape , and a public abstract method show() to output a shape .Derive subclasses for lines, circles and rectangles. Also define the class POLYLINE with SHAPE as the base class. You can represent a line as two points, a circle as a center and a radius. A rectangle as two points on diagonally opposite corners. Implement...
Purpose: The purpose of this lab is for you to design and implement several classes that use Inheritance. The problem: The program must handle a collection of different 2-dimensional shapes: triangles, rectangles and circles. All shapes have a color (use a Stringl and are either filled or not (use a boolean). All shapes must calculate and return their perimeter, and area. toStrina) for all shapes must implement the standardized formatting for inheritance. You are required to implement each of the...