/* Programmer : Dandy A. Macaubos
Program name : Cube
Date Started : February 4,2009
Date Finished : February 4,2009
Purpose : To have a program using encapsulation
Instructor : Dony Dongiapon
Subject : IT134
*/
import javax.swing.JOptionPane;
public class Cube{
private double width;
private double height;
private double lenght;
public Cube(double wid, double heigh, double len)
{
this.width=wid;
this.height=heigh;
this.lenght=len;
}
private Cube()
{
}
public void SetDimension(double newwidth, double newheight, double newlength)
{
this.width=newwidth;
this.height=newheight;
this.lenght=newlength;
}
private double volume(){
return width*lenght*height;
}
private double area(){
return width*lenght;
}
public String displayCube(){
return String.format(volume()+" and "+area());
}
}
Subscribe to:
Post Comments (Atom)
9:00 PM
ReplyDelete