12/06/2014

BCS2233 OOP: Assignment 3

ASSIGNMENT 3

1. An object represents an entity in the real world and it has state, and behaviors. Define state and behaviour.

2. What is the difference between class and object.

3. What is the difference between overloading and over riding.

4. Define superclass and subclass.


2.  (The Rectangle class) Design a class named Rectangle to represent a rectangle. The class contains:
Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height.

A string data field named color that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.

A no-arg constructor that creates a default rectangle.

A constructor that creates a rectangle with the specified width and height.

A method named getArea() that returns the area of this rectangle.

A method named getPerimeter() that returns the perimeter.

 Draw the UML diagram for the class. Implement the class. Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...