Advertisement
spacerose

lab3(java)

Sep 8th, 2020 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. //public abstract class Furniture
  2.  
  3. public abstract class Furniture {
  4.     public String name;
  5.     public String color;
  6.     public int year;
  7.     public double price;
  8.  
  9.     public abstract void getName();
  10.  
  11.     public abstract void getColor();
  12.  
  13.     public abstract void getPrice();
  14.  
  15. }
  16.  
  17.  
  18. //FurnitureType
  19.  
  20. public class FurnitureType extends Furniture {
  21.  
  22.     public FurnitureType(String name, String color, int year,double price) {
  23.         this.name = name;
  24.         this.color = color;
  25.         this.year = year;
  26.         this.price = price;
  27.     }
  28.  
  29.  
  30.  
  31.     @Override
  32.     public void getName()
  33.     {
  34.         System.out.println("Type of furniture: " + name);
  35.     }
  36.  
  37.     @Override
  38.     public void getColor()
  39.     {
  40.         System.out.println("Color: " + color);
  41.     }
  42.  
  43.     @Override
  44.     public void getPrice()
  45.     {
  46.         System.out.println("This item costs " + price);
  47.     }
  48. }
  49.  
  50.  
  51. //FurnitureShop
  52.  
  53. public class FurnitureShop {
  54.  
  55.     public static void main(String[] args) {
  56.  
  57.         FurnitureType item= new FurnitureType("table","black",2019,4532.632);
  58.         item.getName();
  59.         item.getColor();
  60.         item.getPrice();
  61.     }
  62.  
  63. }
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement