Question
public class Computer { private String manufacturer; private String processor; private int ramSize; private int diskSize; private double processorSpeed; public Computer(String man, String pro, int
public class Computer { private String manufacturer; private String processor; private int ramSize; private int diskSize; private double processorSpeed;
public Computer(String man, String pro, int raSize, int diSize, double proSpeed) { manufacturer = man; processor = pro; ramSize = raSize; diskSize = diSize; processorSpeed = proSpeed; }
public String getManufacturer() { return manufacturer; }
public int getRamSize() { return ramSize; }
public int getDiskSize() { return diskSize; }
public double getProcessorSpeed() { return processorSpeed; }
public String getModel() { return this.getManufacturer() + "_" + this.getProcessorSpeed(); }
}
public class Tablet extends Computer{ private int length; private int width; private String operatingSystem;
public Tablet(String man, String pro, int raSize, int diSize, double proSpeed, int len, int wid, String os) { super(man, pro, raSize, diSize, proSpeed); length = len; width = wid; operatingSystem = os; }
public int getArea() { return length * width; }
@Override public String toString() { return "My Tablet was made by: " + getManufacturer() + ", and has a screen area of: " + getArea(); }
}
public class Notebook extends Computer{ public Notebook(String man, String pro, int raSize, int diSize, double proSpeed) { super(man, pro, raSize, diSize, proSpeed); } }
1. For this exercise, you will be writing a new method for the Tablet class. Write a method that overrides Computer getModel, that adds the length and width to the string returned.
For example:
- If I had a Computer object where manufacturer = "MAN" and processorSpeed = 5.5, then running getModel would return the string "MAN_5.5"
- If I had a Tablet where Manufacturer was MAN, processorSpeed was 5.5, length was 11, and width was 8.5, then running getModel would return "MAN_5.5_8.5_11"
Your Answer:
@Override public String getModel() { }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started