Programmed in Java, please use inheritance, as that is the part i'm confused on. Thanks!
For this lab you are creating 4 classes:
Has the main method and tests the other classes.
Write the appropriate constructors, getters and setters in each class.
In your main class create a laptop with an I7 10 generation 3.5 GHZ CPU, 16 GB of RAM and a battery that lasts 10 hours.
You will also need to create a Desktop with the same specs that has 2 screens.
Use the toString method to print the details for your laptop and desktop.
Computer.java
======================
package computer;
public class Computer {
// Parent class
// other class derived from this class
// data members
private String CPU_type; // type of CPU
private double CPU_speed; // CPU speed in GHZ
private int RAM_size; // size of RAM in GB
// default constructor
public Computer() {
// initialize data members
CPU_type = "";
CPU_speed = 0;
RAM_size = 0;
}
// constructor with parameters
public Computer(String CPU_type, double CPU_speed, int
RAM_size) {
// initialize data members
// this indicates current instance
of class,
// it is used to make parameter
name distinguish from member data names
this.CPU_type = CPU_type;
this.CPU_speed = CPU_speed;
this.RAM_size = RAM_size;
}
// getters
public String getCPUType() {
return CPU_type;
}
public double getCPUSpeed() {
return CPU_speed;
}
public int getRAMSize() {
return RAM_size;
}
// setters
public void getCPUType(String CPU_type) {
this.CPU_type = CPU_type;
}
public void getCPUSpeed(double CPU_speed) {
this.CPU_speed = CPU_speed;
}
public void getRAMSize(int RAM_Size) {
this.RAM_size = RAM_Size;
}
// returns all data members in string form
public String toString() {
String str = "CPU Type: " +
CPU_type + "\nCPU Speed: " + CPU_speed + " GHZ\nRAM Size: " +
RAM_size + " GB\n";
return str;
}
}
=============================
Laptop.java
=============================
package computer;
public class Laptop extends Computer{
// child class of Computer class
// data members
private int batteryLife; // Battery life in
hours
private int batteryLevel; // The current battery level
(hours remaining)
// default constructor
public Laptop() {
super();
batteryLife = 0;
batteryLevel = batteryLife;
}
// constructor with parameters
public Laptop(String CPU_type, double CPU_speed, int
RAM_size, int batteryLife) {
// initialize data members
// call to parent class constructor
to initialize its data
super(CPU_type, CPU_speed,
RAM_size);
this.batteryLife =
batteryLife;
batteryLevel = batteryLife; //
Laptops sold are fully charged
}
// getters
public int getBatteryLife() {
return batteryLife;
}
public int getBatteryLevel() {
return batteryLevel;
}
// setters
public void setBatteryLife(int batteryLife) {
this.batteryLife =
batteryLife;
}
public void setBatteryLevel(int batteryLevel) {
this.batteryLevel =
batteryLevel;
}
// sets the battery level to the max level
public void charge() {
setBatteryLevel(batteryLife);
}
// returns all data members in string form
public String toString() {
String str = "Laptop: \n" +
super.toString() // call to parent class's to string method to
print its data first
+ "Battery Life:
" + batteryLife + " Hrs\n" + "Current Bettery Level: " +
batteryLevel + " Hrs\n";
return str;
}
}
=================================
Desktop.java
=================================
package computer;
public class Desktop extends Computer{
// child class of Computer class
// data members
private int screens; // Number of screens
// default constructor
public Desktop() {
super();
screens = 0;
}
// constructor with parameters
public Desktop(String CPU_type, double CPU_speed, int
RAM_size, int screens) {
// initialize data members
// call to parent class constructor
to initialize its data
super(CPU_type, CPU_speed,
RAM_size);
this.screens = screens;
}
// getters
public int getScreens() {
return screens;
}
// setters
public void setScreens(int screens) {
this.screens = screens;
}
// returns all data members in string form
public String toString() {
String str = "Desktop: \n" +
super.toString() // call to parent class's to string method to
print its data first
+ "Number of
Screens: " + screens + "\n";
return str;
}
}
=========================
Tester.java
=========================
package computer;
public class Tester {
// main method to run the program
public static void main(String[] args) {
// create a laptop with an I7 10
generation 3.5 GHZ CPU, 16 GB of RAM and a battery that lasts 10
hours
Laptop laptop = new Laptop("I7 10
generation", 3.5, 16, 10);
// create a Desktop with the same
specs that has 2 screens
Desktop desktop = new Desktop("I7
10 generation", 3.5, 16, 2);
// print the details for laptop and
desktop
System.out.println(laptop);
System.out.println(); // print
empty line
System.out.println(desktop);
}
}

let me know if you have any problem or doubts. thank you.
Programmed in Java, please use inheritance, as that is the part i'm confused on. Thanks! For...
write a C++ program using classes, friend functions and overloaded operators. Computer class: Design a computer class (Computer) that describes a computer object. A computer has the following properties: Amount of Ram in GB (examples: 8, 16), defaults to 8. Hard drive size in GB (examples: 500, 1000), defaults to 500. Speed in GHz (examples: 1.6, 2.4), defaults to 1.6. Type (laptop, desktop), defaults to "desktop" Provide the following functions for the class: A default constructor (constructor with no parameters)...
Please include comments in java Create a command line program that can be used for computer inventory purposes Create a super class that will store the following data: CPU speed Amount of RAM Hard Disk size Operating System Allow the user to enter data using any units of measurement they desire (i.e. - 500GB or 1TB for hard disk size). Create a class that inherits from the previous class and stores information for a Windows based computer. Store the following...
I'm still fairly new to java and I haven't programmed with it in half a year, so I can't for the life of me figure this out even though I know its really simple. I'll paste the 2 classes below so any help is much appreciated. The TODO comments are what I'm supposed to do. public class Main { public static void main(String[] args) { /* * This is for the first part of the lab. */ Planner coursePlan...
In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...
in java : Create Java Application you are to create a project using our designated IDE (which you must download to your laptop). Create the code to fulfill the requirements below. Demonstrate as stipulated below. Create a Main Application Class called AddressBookApplication (a counsole application / command line application). It should Contain a Class called Menu that contains the following methods which print out to standard output a corresponding prompt asking for related information which will be used to update...
Project 4: Pet Store Objectives: Create multiple classes in an inheritance hierarchy Use an abstract class Use polymorphism Use an ArrayList Assignment For this project, you get to write a simplified pet store inventory program in Java. To complete this, you will need to have the following classes: Main class PetStore class Pet class Bird class Reptile class Snake class Turtle class Main class: This class is a driver class for the PetStore class. It is not part of the...
JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...
Description: You have been asked to help the College of IST Running Club by designing a program to help them keep track of runners in the club, the races that will occur, and each runner's performance in each race! Requirements: Please use Java to implement the program Your program must: Store information about each Runner. Store information about each Race. Store information about the performance of each runner in each race that they compete in. Note that each race may...
CSBP 319 Data structures - Linked Lists - USE JAVA (NetBeans) A company would like to implement its inventory of computing machines as a linked list, called ComputerList. Write a Computer node class, called ComputerNode, to hold the following information about a Computer: • code (as a String) • brand (as a String) • model (as a String) • price (as double) • quantity (as int) ComputerNode should have constructors and methods (getters, setters, and toString()) to manage the above...