class Fruits
{
boolean countable;
Fruits(boolean c)
{
countable = c;
}
void display()
{
System.out.println("Countable Fruit: " +countable);
}
}
class Watermelon extends Fruits
{
float price;
int quantity;
Watermelon(float p, int q, boolean c)
{
super(c);
price = p;
quantity = q;
}
void show()
{
System.out.println("Price: "+ price);
System.out.println("Quantity: "+ quantity);
display();
}
}
class Exp6_3
{
public static void main(String[] args)
{
Watermelon ob1, ob2, ob3;
ob1 = new Watermelon(10.25F, 100, true);
ob2 = new Watermelon(8.75F, 70, false);
ob3 = new Watermelon(20.50F, 97, true);
ob1.show();
ob2.show();
ob3.show();
}
}
/* OUTPUT!!!
Price: 10.25
Quantity: 100
Countable Fruit: true
Price: 8.75
Quantity: 70
Countable Fruit: false
Price: 20.5
Quantity: 97
Countable Fruit: true
*/
{
boolean countable;
Fruits(boolean c)
{
countable = c;
}
void display()
{
System.out.println("Countable Fruit: " +countable);
}
}
class Watermelon extends Fruits
{
float price;
int quantity;
Watermelon(float p, int q, boolean c)
{
super(c);
price = p;
quantity = q;
}
void show()
{
System.out.println("Price: "+ price);
System.out.println("Quantity: "+ quantity);
display();
}
}
class Exp6_3
{
public static void main(String[] args)
{
Watermelon ob1, ob2, ob3;
ob1 = new Watermelon(10.25F, 100, true);
ob2 = new Watermelon(8.75F, 70, false);
ob3 = new Watermelon(20.50F, 97, true);
ob1.show();
ob2.show();
ob3.show();
}
}
/* OUTPUT!!!
Price: 10.25
Quantity: 100
Countable Fruit: true
Price: 8.75
Quantity: 70
Countable Fruit: false
Price: 20.5
Quantity: 97
Countable Fruit: true
*/