Selasa, 01 Desember 2009

SET BOX

/*----------------------------------------------------------------------------
SETTING BOX
----------------------------------------------------------------------------*/
#include
#include
#include
//=============================================================================
// deklarasi class box

class Box {
private :
int length; // panjang
int width; // lebar
public :
Box(){ //constructur
length=15;
width =10;}
void setBox(int xwidth,int xlength){
length = xlength;
width = xwidth;}
int getlength() // melihat berapa panjang box
{int l;l=length;return(l);}
int getwidth() // melihat berapa lebar box
{int w;w=width;return(w);}
int getArround()// menghitung keliling box
{int Ar;Ar=(length+width)*2;return(Ar);}
int getArea() // menghitung luas box
{int A;A=length*width;return(A);}
void display();
};

void Box::display(){
int i,x1,x2,y1,y2;
x1=2;y1=2;x2=getwidth();y2=getlength();
for(i=y1+1;i<=y2-1;i++){gotoxy(i,x1);printf("%c",205);gotoxy(i,x2);printf("%c",205);}
for(i=x1+1;i<=x2-1;i++){gotoxy(y1,i);printf("%c",186);gotoxy(y2,i);printf("%c",186);}
gotoxy(y1,x2);printf("%c",200);gotoxy(y1,x1);printf("%c",201);
gotoxy(y2,x1);printf("%c",187);gotoxy(y2,x2);printf("%c",188); }

void main(){
Box b1;
Box b2;
b2.setBox(15,45);
cout<<"\n RINCIAN BOX : \n";
cout<<"\n Box 1 : PANJANG : "< cout<<"\n LEBAR : "< cout<<"\n KELILING : "< cout<<"\n LUAS : "<cout<<"\n\n Box 2 : PANJANG : "< cout<<"\n LEBAR : "< cout<<"\n KELILING : "< cout<<"\n LUAS : "<cout<b1.display();
getch();
}

Tidak ada komentar:

Posting Komentar