arianramianpour - Hightechrobo Bin
  JAVA   124

arianramianpour

Guest on 3rd January 2022 08:57:25 AM

  1. package com.company;
  2.  
  3.  
  4. abstract class computer{
  5.     private String owner;
  6.     private int ram;
  7.     private String os;
  8.     private cpu cpu;
  9.  
  10.     public computer() {
  11.         owner = "";
  12.         ram = 0;
  13.         os = "";
  14.         cpu = new cpu();
  15.     }
  16.  
  17.     public computer(String owner, int ram, String os, cpu cpu) {
  18.         this.owner = owner;
  19.         this.ram = ram;
  20.         this.os = os;
  21.         this.cpu = cpu;
  22.     }
  23.  
  24.     public String getOwner() {
  25.         return owner;
  26.     }
  27.  
  28.     public void setOwner(String owner) {
  29.         this.owner = owner;
  30.     }
  31.  
  32.     public int getRam() {
  33.         return ram;
  34.     }
  35.  
  36.     public void setRam(int ram) {
  37.         this.ram = ram;
  38.     }
  39.  
  40.     public String getOs() {
  41.         return os;
  42.     }
  43.  
  44.     public void setOs(String os) {
  45.         this.os = os;
  46.     }
  47.  
  48.     public cpu getcpu() {
  49.         return cpu;
  50.     }
  51.  
  52.     public void setcpu(cpu cpu) {
  53.         this.cpu = cpu;
  54.     }
  55.     public abstract double boot();
  56.  
  57.     @Override
  58.     public String toString() {
  59.         return "computer{" +
  60.                 "owner='" + owner + '\'' +
  61.                 ", ram=" + ram +
  62.                 ", os='" + os + '\'' +
  63.                 ", cpu=" + cpu +
  64.                 '}';
  65.     }
  66. }
  67. class cpu{
  68.     private String company;
  69.     private String model;
  70.     private int speed;
  71.  
  72.     public cpu() {
  73.         company = "";
  74.         model = "";
  75.         speed = 0;
  76.     }
  77.  
  78.     public cpu(String company, String model, int speed) {
  79.         this.company = company;
  80.         this.model = model;
  81.         this.speed = speed;
  82.     }
  83.  
  84.     public String getCompany() {
  85.         return company;
  86.     }
  87.  
  88.     public void setCompany(String company) {
  89.         this.company = company;
  90.     }
  91.  
  92.     public String getModel() {
  93.         return model;
  94.     }
  95.  
  96.     public void setModel(String model) {
  97.         this.model = model;
  98.     }
  99.  
  100.     public int getSpeed() {
  101.         return speed;
  102.     }
  103.  
  104.     public void setSpeed(int speed) {
  105.         this.speed = speed;
  106.     }
  107.  
  108.     @Override
  109.     public String toString() {
  110.         return "cpu{" +
  111.                 "company='" + company + '\'' +
  112.                 ", model='" + model + '\'' +
  113.                 ", speed=" + speed +
  114.                 '}';
  115.     }
  116. }
  117. class Laptop extends computer {
  118.     private String brand;
  119.     private int price;
  120.  
  121.     public Laptop() {
  122.         super();
  123.         brand = "";
  124.         price = 0;
  125.  
  126.     }
  127.  
  128.     public Laptop(String owner, int ram, String os, cpu cpu, String brand, int price) {
  129.         super(owner, ram, os, cpu);
  130.         this.brand = brand;
  131.         this.price = price;
  132.     }
  133.  
  134.     public String getBrand() {
  135.         return brand;
  136.     }
  137.  
  138.     public void setBrand(String brand) {
  139.         this.brand = brand;
  140.     }
  141.  
  142.     public int getPrice() {
  143.         return price;
  144.     }
  145.  
  146.     public void setPrice(int price) {
  147.         this.price = price;
  148.     }
  149.  
  150.     @Override
  151.     public String toString() {
  152.         return "Laptop{" +
  153.                 "brand='" + brand + '\'' +
  154.                 ", price=" + price +
  155.                 '}';
  156.     }
  157.  
  158.     @Override
  159.    public double boot () {
  160.  
  161.  
  162.     }
  163.  
  164. }
  165. public class Main {
  166.  
  167.     public static void main(String[] args) {
  168.         System.out.println("Welcome please enter the things");
  169.  
  170.     }
  171. }


Add Comment

* Required information
1000
Drag & drop images (max 3)
What is the sum of 1 + 2 + 3?
Captcha Image
Powered by Commentics

Comments

No comments yet. Be the first!

Raw Paste


Login or Register to edit or fork this paste. It's free.