Question: Homework must be done in Java. Implement the following classes/interfaces, obeying the following: 1. ElectronicDevice (an interface), with the following o A getSummary() method that

Homework must be done in Java.

Implement the following classes/interfaces, obeying the following:

1. ElectronicDevice (an interface), with the following

o A getSummary() method that returns a String

2. PowerSource (a concrete class), which supports the following:

o Holds up to 6 ElectronicDevice objects in a private array named devices o An attach() method that takes any kind of Electronic device and adds it to the devices array

o Has a printInventory() method that prints each electronic device on the "devices" arrray on a separate line, based on the results that getSummary() returns for that device

3. Computer (an abstract class that implements the ElectronicDevice interface), with the following:

o Private internal variables: name (String) and storage (int)

o Constructor that takes name (String) and storage (int) as parameters. The storage parameter is just a number, there are no units (like GB or MB)

o Can be assigned a Printer, as shown in ComputerLand code

o Must support a save() method that takes an amount of storage needed, as a parameter, and decrements the storage available (no filenames required)

o Has an abstract method called getOperatingSystem() that returns a String

o Provides an implementation of getSummary() (see example output below)

4. Printer (an interface that is a type of ElectronicDevice)

o Supports print() method that takes a jobName (String) and number of pages (int). It returns nothing.

o Supports a scan() method that takes a jobName, number of pages to scan, and reference to a Computer to save the data to. It returns nothing.

5. AppleMacbook (a concrete type of Computer)

o Runs the "OS X" operating system

6. DellDesktop (a concrete type of Computer)

o Runs the "Windows" operating system

7. EpsonPrinter (a concrete type of Computer that also can act as a Printer)

o Every page virtually scanned requires 5 storage units on target computer

o Logs each virtual scan to ouput (see below)

o Logs each page virtually printed (as it is printed) to output (see below)

o Has "Linux" operating system

8. ComputerLand (included, see below)

Homework must be done in Java. Implement the following classes/interfaces, obeying the

following: 1. ElectronicDevice (an interface), with the following o A getSummary() method

You must combine your work with the following code, which is provided: public class ComputerLand ( public static void main(String[] args) { Computer mac new AppleMacbook("MyMac", 1000); Computer dell - new DellDesktop("MyDell", 500); Printer epson = new EpsonPrinter("My Epson", 2); PowerSource source new PowerSource(); source.attach(mac); source.attach(del1); source.attach (epson) mac.setPrinter(epson); dell.setPrinter(epson); mac.scan ( "Passport application", 10); mac.print( "Story", 5); dell.scan( "Taxes", 25); dell.print("License agreement", 2); source.printInventory(); You must combine your work with the following code, which is provided: public class ComputerLand ( public static void main(String[] args) { Computer mac new AppleMacbook("MyMac", 1000); Computer dell - new DellDesktop("MyDell", 500); Printer epson = new EpsonPrinter("My Epson", 2); PowerSource source new PowerSource(); source.attach(mac); source.attach(del1); source.attach (epson) mac.setPrinter(epson); dell.setPrinter(epson); mac.scan ( "Passport application", 10); mac.print( "Story", 5); dell.scan( "Taxes", 25); dell.print("License agreement", 2); source.printInventory()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!