C++代写:CS2370 Elecrtonic Devices

代写一个计算机硬件设备小程序,练习面向对象编程设计。

Important

  • Do you own work
  • No late assignments accepted
  • Only turn in .cpp and .h files, no ZIP files or anything else (50% penalty if not)

You will be constructing a series of elecrtonic devices and integrating them in a short program.
You will draw heavily from our discussions of classes and abstract classes.

What you need to do

You will need to implement the following classes, obeying the instructions below (but there may be more you need to do, based on ComputerLand code). Each class must have its own .cpp and .h file.

  • PowerSource (a concrete class), which supports the following:
    • Holds up to 6 ElectronicDevice objects (in an array)
    • An attach() method, per use in ComputerLand
    • Has a printInventory() method that calls getSummary() on all its devices
  • ElectronicDevice (an abstract class), with the following
    • A pure virtual method called getSummary() that returns a String
  • Computer (an abstract class that is a type of ElectronicDevice), with the following:
    • 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).
    • Can be associated with a Printer, as shown in ComputerLand code
    • Must support a save() method that takes an amount of storage needed and decrements the storage available (no filenames required).
    • Provides print() and scan() functions, which leverage the Printer. When scanning, should call local save() (each page requires 5 units of storage)
    • Has an abatract method called getOperatingSystem() that returns a String
    • Implements getSummary()
  • Printer (an abstract class that is a type of ElectronicDevice)
    • Supports pure virtual method print() method that takes a jobName (String) and number of pages (int). It returns nothing.
    • Supports pure virtual methods scan() method that takes a jobName, number of pages to scan. It returns nothing.
  • AppleMacbook (a concrete type of Computer)
    • Must call superclass constructor. Has “OS X” operating system
  • DellDesktop (a concrete type of Computer)
    • Must call superclass constructor. Has “Windows” operating system
  • EpsonPrinter (a concrete type of Computer that also can act as a Printer)
    • Must call superclass constructor
    • Logs each virtual scan to output (see below)
    • Logs each page virtually printed (as it is printed) to output (see below)
    • Has “Linux” operating system
  • ComputerLand (included, see below)

You must combine your work with the following ComputerLand.cpp file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int main() { 
Computer* mac = new AppleMacbook("MyMac", 1000);
Computer* dell = new DellDesktop("MyDell", 500);
EpsonPrinter* epson = new EpsonPrinter("MyEpson", 2);

PowerSource* source = new PowerSource();

source->attach(mac);
source->attach(dell);
source->attach(epson);

mac->addPrinter(epson);
dell->addPrinter(epson);

mac->scan("Passport application", 10);
mac->print("Story", 5);

dell->scan("Taxes", 25);
dell->print("License areement", 2);

source->printInventory();
}

so that the following is produced (exactly) when ComputerLand is run:

Scanning 10 pages of Passport application
Printing page 5 of Story
Printing page 5 of Story
Printing page 5 of Story
Printing page 5 of Story
Printing page 5 of Story
Scanning 25 pages of Taxes
Printing page 2 of License areement
Printing page 2 of License areement
=== INVENTORY ===
MyMac, running OS X with storage = 950
MyDell, running Windows with storage = 375
MyEpson, running Linux with storage = 2