Course title: CSC 1205: Object Oriented Programming 1 (JAVA)
Topic: Developing a basic java class with Inheritance.
Look at the following class notation and class diagram carefully. Then develop the program.
Lab Task 1 Lab Task 2
Class Diagram Class Diagram
Shape Shape
double x double x
Shape() Shape()
Shape(double x) Shape(double x)
void setX(double x) void setX(double x)
double getX() double getX()
double getArea() double getArea()
//returns -9.99 as shape has no area to calculate //returns -9.99 as shape has no area to calculate
Circle Square
Circle() Square()
Circle(double x) Square(double x)
double getArea() double getArea()
//calculate and returns the area of the circle (πx2) //calculate and returns the area of the square (x2)
void showInfo() void showInfo()
Rectangle Triangle
double y double y
Rectangle() Triangle()
Rectangle(double x, double y) Triangle(double x, double y)
void setY(double y) void setY(double y)
double getY() double getY()
double getArea() double getArea()
//calculate and returns the area of the rectangle (xy) //calculate and returns the area of the rectangle (0.5xy)
void showInfo() void showInfo()
Start Start
The Start class contains the main method. Inside the main The Start class contains the main method. Inside the main
method, create two objects of Circle class and two objects method, create two objects of Square class and two objects
of Rectangle class. of Triangle class.
Then demonstrate all the methods and constructors. Then demonstrate all the methods and constructors.