12/01/2012

BCS2233 OOP: CREATING CLASS

Write a class for each of the following specifications. In each case, include a constructor that set each member values to 0 and a member method named showdata() that can be used to display member values.

1. A class named TIME that has integer data members named SECS, MINS, and HOURS.                                

 2. A class named TRIANGLE that has integer data members LENGTH and WIDTH.  


3. A class named STUDENT that has string data members named NAME, ADDRESS and COURSE and a floating point data member named CPA.                



Jawapan untuk soalan 1.

class TIME {
private int SECS, MINS, HOURS;

TIME() {
SECS= MINS= HOURS=0;
}

public showdata() {
System.out.println("Second="+SECS);
System.out.println("Minute="+MINS);
System.out.println("Hour="+HOURS);
}

}

UML untuk class TIME  adalah spt berikut:

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.  ...