6/14/2017

BCS2233 OOP. Lab 15 Jun 2017 (INHERITANCE)


 Chapter 11 : Inheritance and Polymorphism

  1. Create a class named Rectangle that contains data fields for height and  length and a method named getArea() that returns the area of this Rectangle.
Create a child class (derived from Rectangle) named Cube. Cube contains an additional data field named depth, and a getArea() method that overrides the parent method.
Draw the UML diagram for the class (Class Rectangle and Class Cube) and then implement the class. Write a test program that creates one Rectangle object with height 4 and length 40 and one Cube object height 15, length 20 and depth 45.

Display height, length and area of each object.


  1. Create a base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Circle with another data member named radius. For this derived class, the x and y data members represent a circle’s centre coordinates. The member method of the Point class should consist of a constructor that set the value for x and y to 0, an area() method that return 0.



The derived class should has an override method named area() that return’s a circle area

Area = 3.14 x radius2.

Draw UML diagram for the class Point and class Circle and then implement the class. Write a test program that creates one Point object and one Circle object with x 5, y 7 and radius 13. Display x and y for Point Object; x, y and radius for Circle Object.

 

6/11/2017

BCS2233 OOP: Assignment 2

Assalamualaikum.

Assignment kedua untuk BCS2233 OOP boleh di muat turun dari sini.
Soalan 0 adalah contoh yang telah di sertakan penyelesaiannya.
Tarikh Hantar adalah  22 / Jun / 2017.


Ada kesilapan pada dokumen sebelum. Pembetulan bagi soalan tersebut boleh di muat turun dari SINI.


6/07/2017

BCS2233 OOP. Lab 8 Jun 2017

Chapter 9 : Objects and Classes
Give both traditional and Object Oriented approach solution for the following problems.
 
1.    Write a java program that reads the length and height of a rectangle and computes its area and parameter using the following formulas:-
Area = length x height
Perimeter = 2 x (length + height)



OOP:

2.    Write a java program that reads the height of a cube  and computes its area and parameter using the following formulas:-
Area = height2
Perimeter = 4 x height

TRA:



3.    Write a program that reads in the radius and length of a cylinder and computes its volume using the following formulas:

Area = radius * radius * 3.14
Volume = area * length


TRA:


 

BCS2233 OOP. Lab 15 Jun 2017 (INHERITANCE)

  Chapter 11 : Inheritance and Polymorphism Create a class named Rectangle that contains data fields for height and   length ...