9/28/2010

BCS2234 27/9/ 2010 Lab OOP (defining class for objects) 2




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 (one) 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.

*Please refer to previous lab activities as a guidance

9/27/2010

BCS2234 27/9/ 2010 Lab OOP









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

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


**
* @(#)class_rec.java
*
* class_rec application
*
* @author
* @version 1.00 2010/9/27
*/

public class class_rec {

public static void main(String[] args) {

// TODO, add your application code
System.out.println("Hello World!");
rectangle myrectangle = new rectangle(3,4);
System.out.println(myrectangle.width + " " + myrectangle.length);
System.out.println(myrectangle.getArea());


rectangle yourrectangle = new rectangle();
System.out.println(yourrectangle.width + " " + yourrectangle.length);
System.out.println(yourrectangle.getArea());

}
}


class rectangle {
int width, length;

rectangle() { // constructor for default rectangle
width =1;
length =1;
}

rectangle(int newwidth, int newlength) { // constructor for specified width and height.
width =newwidth;
length = newlength;
}

int getArea() // getArea()method
{
return width*length;
}

} //end rectangle class

9/21/2010

BCS2234 Test 1

Topics Covered:- Chapter 1 to Chapter 5
Questions Type:- Definition, Identify identifier, Evaluate Math Expression , write a java program on various loop , Write a header of methods.

Date : 30/9/2010
Time : 11:00 am - 12:30 am

This is an open book test.

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