Prostopadloscian1.java
/* Prostopadloscian1.java */
class Prostokat
{
int a;
int b;
int pole()
{
return a*b;
}
Prostokat(int a, int b)
{
this.a = a;
this.b = b;
}
}
class Prostopadloscian
{
Prostokat podstawa;
int wysokosc;
int objetosc()
{
return podstawa.pole() * wysokosc;
}
Prostopadloscian(int a, int b, int c)
{
podstawa = new Prostokat(a,b);
wysokosc = c;
}
}
public class Prostopadloscian1
{
public static void main(String[] args)
{
Prostopadloscian pr1 = new Prostopadloscian(2,3,4);
System.out.println("a = " + pr1.podstawa.a);
System.out.println("b = " + pr1.podstawa.b);
System.out.println("c = " + pr1.wysokosc);
System.out.println("Objetosc pr1 = " + pr1.objetosc());
}
}
a = 2
b = 3
c = 4
Objetosc pr1 = 24
Press any key to continue...