Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Fruit {
- private String color;
- private double weight;
- public Fruit(String c,double w)
- {
- color=c;
- weight=w;
- }
- public void buyFruit(double p)
- {
- System.out.println("Price: "+p);
- System.out.println("Weight: "+weight);
- }
- public void checkFruit(int py,int quan,int a)
- {
- System.out.println("Sticker ID: "+a);
- System.out.println("Color: "+color);
- System.out.println("Production Year: "+py);
- System.out.println("Quantity: "+quan);
- }
- }
- public class Sticker {
- private int sID;
- public Sticker(int s)
- {
- sID=s;
- }
- public int getSID()
- {
- return sID;
- }
- }
- public class Apple extends Fruit {
- private static double price;
- private static int pYear;
- private static int quantity;
- Sticker o2;
- public Apple(double pr,int py,int quan)
- {
- super("Green",3);
- price=pr;
- pYear=py;
- quantity=quan;
- }
- public void eat()
- {
- System.out.println("Eat fresh fruits");
- }
- public void clean()
- {
- System.out.println("Wash your fruit before you eat");
- }
- public static void main(String[] args) {
- Apple o1 = new Apple(410.50,2020,2);
- Sticker o2 = new Sticker(150);
- int a=o2.getSID();
- o1.buyFruit(price);
- o1.checkFruit(pYear,quantity,a);
- o1.clean();
- o1.eat();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement