0% found this document useful (0 votes)
8 views1 page

Java Inheritance Basics: Class Development

The document outlines a course task for CSC 1205: Object Oriented Programming 1 (JAVA), focusing on developing basic Java classes with inheritance. It provides class diagrams for various shapes, including Circle, Square, Rectangle, and Triangle, detailing their attributes and methods. The task involves creating objects of these classes and demonstrating their functionalities in the main method of the Start class.

Uploaded by

rsadat.darkangel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Java Inheritance Basics: Class Development

The document outlines a course task for CSC 1205: Object Oriented Programming 1 (JAVA), focusing on developing basic Java classes with inheritance. It provides class diagrams for various shapes, including Circle, Square, Rectangle, and Triangle, detailing their attributes and methods. The task involves creating objects of these classes and demonstrating their functionalities in the main method of the Start class.

Uploaded by

rsadat.darkangel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like