rangga_hrdme

OOP-JAVA:CLASS2-INHERITANCE

May 5th, 2021
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. public class Laptop {
  2.  
  3.     protected String mark, ram, proceSsor, graphic, country;
  4.  
  5.     public static void main(String[] args) {
  6.         Laptop dell = new Laptop("indonesia", "dell vostro", "8gb", "i5", "nvidia");
  7.         Laptop hp = new Laptop("singapore", "hp pavilion", "12gb", "i3", "radeon");
  8.         Laptop asus = new Laptop("USA", "asus rog", "32gb", "i7", "intel hd");
  9.  
  10.         dell.printLaptop();
  11.         hp.printLaptop();
  12.         asus.printLaptop();
  13.     }
  14.  
  15.     public Laptop(String country, String mark, String ram, String proceSsor, String graphic) {
  16.         this.country = country;
  17.         this.mark = mark;
  18.         this.ram = ram;
  19.         this.proceSsor = proceSsor;
  20.         this.graphic = graphic;
  21.     }
  22.  
  23.     public void printLaptop() {
  24.         System.out.println(
  25.                 "Country: " + this.country
  26.                         + ", Graphic Card: " + this.graphic
  27.                         + ", Mark: " + this.mark
  28.                         + ", Processor: " + this.proceSsor
  29.                         + ", RAM: " + this.ram
  30.         );
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment