Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the class Device. In this question, you are required to declare all the attributes and methods (the constructor, the getters/setter methods...) as presented in

image text in transcribed

Implement the class Device. In this question, you are required to declare all the attributes and methods (the constructor, the getters/setter methods...) as presented in the UML diagram.

  1. The class is abstract and contains an abstract method named isAlternative.
  2. The method toString method returns a String of the form Brand: . Price: . dollars.

Implement the class Laptop. It has two private attributes. The cpu (corei5, corei7) and the type that indicates whether the Laptop is ultrabook, notebook, etc.

  1. Implement the constructor and the getter/setter methods
  1. b.The toString method returns a String of the form:

Laptop Brand: . Price . dollars.

Cpu: And Type:

the USB code:

public class Usb extends Device {

private int storage;

public Usb(String brand, double price, int s) {

super(brand, price);

this.storage = s;

}

@Override

public String toString() {

return "Usb " + super.toString() + " Storage is" + storage + " GB " ;

}

@Override

public boolean isAlternative(Object o) {

return true;

}}

Continue the implementation of the class Laptop

  1. Implement the isAlternative method of signature public boolean isAlternative (Object o). Two Laptops are alternatives if they have the same type and the same cpu.

Implement the class TechShop.

  1. Constructor: set the name of the TechShop, and initializes the ArrayList for devices.
  2. addDevice (device: Device) : This method adds a Device to devices ArrayList.
  3. getDevices() : This method returns the list of devices.

Continue the implementation of the class TechShop. Implement the toString method. It returns information about all the devices in the ArrayList devices.

TechShop Name: Modern Technology

Devices: Laptop Brand: HP Price: 500 dollars.

Cpu: corei7 And Type:Ultrabook

Laptop Brand: Lenovo Price 600 dollars.

Cpu: corei5 And Type:Notebook

Usb Brand: SanDisk Price: 30 dollars.

Storage is 32 GB

main:

  1. Creates a TechShop called Modern Technology.
  2. Add three objects to the TechShop, two Laptops (Laptop1 and Laptop2) and a USB from values set by the programmer.
  3. Display information about all the Laptops in the TechShop that could be alternative to Laptopl.
  4. Display all information about laptops in the TechShop whose type is Ultrabook and cpu is corei7.

java.util.ArrayList

+ArrayList()

+add(o: E): void

+add(index: int, o: E): void

+clear(): void

+contains(o: Object): boolean

+get(index: int): E

+indexOf(o: Object): int

+isEmpty(): boolean

+lastIndexOf(o: Object): int

+remove(o: Object): boolean

+size(): int

+remove(index: int): boolean

+set(index: int, o: E): E

TechShop -name: String - devices: ArrayList + TechShop (name: String) + addDexissid: device): void + getswisss(type: int): ArrayList Device + to StringO: String Device #brand: String #price: double + Device (all arguments) + toString(): String + //getters & Setters methods + isAlternativelo: Object): boolean Laptop - spu: String type: String + Laptop (all arguments) + toString0 : String -getCpu:String + gstTypeO:String Usb storage: int + Usb (all arguments) +toString(): String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago