1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marshall27 [118]
3 years ago
11

Design 3 classes: Computer - Superclass

Computers and Technology
1 answer:
wlad13 [49]3 years ago
5 0

Answer:

Explanation:

The following code is written in Java. It creates the three classes mentioned and a Tester class that contains the main method. The Computer class contains the memory variable since both laptops and Desktops need memory. The screen size variable is placed separately in the Laptop and Desktop class since desktops may or may not have a monitor so this variable cannot be placed in the Computer class. The batteryLife variable is only in the Laptop class because Desktops do not have batteries. Finally, the monitor variable is only placed in the Desktop class since Laptop's come with built-in monitors. The tester class seen in the picture below tests the creation of both of these objects and it executes without any error.

class Computer {

   int memory;

   public int getMemory() {

       return memory;

   }

   public void setMemory(int memory) {

       this.memory = memory;

   }

}

class Laptop extends Computer {

   int screenSize;

   double batteryLife;

   public int getScreenSize() {

       return screenSize;

   }

   public void setScreenSize(int screenSize) {

       this.screenSize = screenSize;

   }

   public double getBatteryLife() {

       return batteryLife;

   }

   public void setBatteryLife(double batteryLife) {

       this.batteryLife = batteryLife;

   }

}

class Desktop extends Computer {

   boolean monitor;

   int screenSize;

   public boolean isMonitor() {

       return monitor;

   }

   public void setMonitor(boolean monitor) {

       this.monitor = monitor;

   }

   public int getScreenSize() {

       return screenSize;

   }

   public void setScreenSize(int screenSize) {

       this.screenSize = screenSize;

   }

}

class Tester {

   public static void main(String[] args) {

       Laptop computer1 = new Laptop();

       Desktop computer2 = new Desktop();

   }

}

You might be interested in
It is where your cpu (processor) is installed
Fofino [41]
The motherboard (CPU SOCKET)
4 0
3 years ago
Read 2 more answers
Which of the following players is on offence
Bumek [7]

Answer:

A baseball player trying to steal second base.

Explanation:

From a test I took, im hoping the answer choices were the same as yours tho.

7 0
3 years ago
Select the correct answer from each drop-down menu.
Mashcka [7]

Answer:

plz gie brainlest and anser is down there and ghost should of never been beytread

Explanation:

image editores and  adobe  photo  shop

6 0
3 years ago
Shaniya has misspelled a scientific name in her biology report. She needs to correct it, but she has no access to a computer. Sh
Brums [2.3K]

yes, she can make an account or log onto her school account

7 0
3 years ago
Read 2 more answers
WILL GIVE BRAINLIEST
malfutka [58]

Answer:

25

Explanation:

259÷10=25

4 0
3 years ago
Read 2 more answers
Other questions:
  • Given three dictionaries, associated with the variables, canadian_capitals, mexican_capitals, and us_capitals, that map province
    11·1 answer
  • When you select a state abbreviation from a combo box, how does the form control record your selection?
    8·1 answer
  • How to use command prompt​
    14·1 answer
  • this device can be used to type documents,send email,browse the internet,handle spreadsheets,do presentations,play games,and mor
    14·1 answer
  • Rate monotonic Analysis (RMA) is a model for predicting whether or not a system will meet its timing as well as throughput requi
    6·1 answer
  • LensForAll is a company that sells affordable contact lenses on its website. The CEO of the company realizes that an app must be
    9·1 answer
  • Spreadsheet software can be used to do all the following except _____.
    5·2 answers
  • If a base class pointer, p, points to a derived class instance, and both base and derived classes have a method void doIt() whic
    14·1 answer
  • For python how do I ask the user how many numbers they want to enter and then at the ending add those numbers up together?
    10·1 answer
  • The television is the biggest technological advancement in communication since the telephone.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!