Monday, April 16, 2012

Play With OOP in Java




/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package struktur.data;



class Kotak {
double panjang;
double lebar;
double tinggi;
double luas = panjang*lebar;

Kotak(double p, double l, double t){
this.panjang = p;
this.lebar = l;
this.tinggi = t;


}
double hitungVolume(){
return(panjang*lebar*tinggi);}
}
public class tupen_class {
public static void main(String[] args){
Kotak k1,k2,k3;

k1 = new Kotak(10.2,13.67,12.76);
System.out.println(k1.hitungVolume());


}  
}

No comments:

Post a Comment