Intro to C++ INTRODUCTION: In this assignment you will implement class Printer,
ID: 3830080 • Letter: I
Question
Intro to C++
INTRODUCTION:
In this assignment you will implement class Printer, which represents a real-life computer printer. Your class
Printer contains the following attributes (member variables):
§ Type: Dot Matrix, Ink Jet, or Laser (enum data type)
§ Status: ON or OFF (Boolean value)
§ Printer_Capacity: the maximum number of pages that can be loaded into a printer (integer)
§ Paper_Load: current number of pages loaded into a printer (integer)
Class Printer contains the following FUNCTIONS:
CONSTRUCTORS:
§ Default constructor. Default attribute values are:
o Type = Do Matrix
o Status = OFF
o Printer_Capacity = 1,000
o Paper_Load = 1,000
§ Class Constructor: takes four arguments, one for each class attribute. To receive full credit, make sure
that the arguments for paper capacity and paper load are valid (in other words you must validate the
arguments):
o Printer_Capacity – an integer value between 500 and 10,000
o Paper_Load – and integer value between 0 and Paper Capacity
I/O FUNCTIONS:
§ Input_printer: takes input from the keyboard (a user) to set a printer object and validates attribute
values (member variable values) of the class. Accepts no parameters. Returns Nothing.
§ Display_printer: displays printer information on the screen
ACCESSOR MEMBER FUNCTIONS:
§ Get_Type: returns the type of the printer
§ Get_Status: returns a Boolean value indicating if the printer is ON or OFF
§ Get_Capacity: returns printer’s page capacity
§ Get_Load: returns current printer’s page load
MODIFIER MEMBER FUNCTIONS:
§ Print: prints specified number of pages (e.g. sheets of paper). Function takes a single integer value (as
an argument) to represent the number of pages to print. Printing rules:
o If the printer is OFF return -1.
o Otherwise,
§ If the number of pages to print is larger than the Paper Load then the function sets
Paper Load to 0 and returns the number of pages (int) left to print.
§ Otherwise, the function decrements the Paper Load by the number of pages to print
and returns 0.
§ Load: loads specified number of pages into a printer. Function takes a single int value as an argument
to represent the number of pages to load. Loading rules:
o If the printer’s available capacity (e.g. the difference between the Printer Capacity and the
Paper Load) is greater than the requested number of pages to load, then the function
increments the Paper Load by the specified number of pages and returns 0.
o Otherwise, the function sets Paper Load to the Printer Capacity and returns the number of
pages that were NOT loaded.
ASSIGNMENT:
1. Write definition of class Printer (20 points)
2. Implement class Printer (70 points)
a. Default Constructor (5 points)
b. Class Constructor (10 points)
c. Input Function (15 points)
d. Display (Output) Function (10 points)
e. Accessor Functions (4 functions) (4 points)
f. Function Print (15 points)
g. Function Load (11 points)
3. Implement and test driver functions. Make sure you implement each as a separate function.
These are to be placed in the same file as, and called from, main: (50 points)
a. Function Count_Printers continually asks the user to input printer
information and counts the number of Laser printers inputted. The
function terminates only when the user indicates that there are no
more printers to input. The function returns an integer value, which
is the number of Laser printers input from the user. (10 points)
b. Function Find_Printer takes one parameter of type integer, which
is the size of the print job (e.g. the number of pages to print). The
function continually asks the user to input printer information and
displays those printers that are currently ON and that can print the
job of specified size (e.g. the Paper_Load is larger than or equal to
the print job). The function terminates when the user indicates that
there are no more printers to input. If there are printers that can
process a job of the specified size then the function returns the
printer with the largest Paper_Load. Otherwise, the function
returns a printer created using the default constructor. Hint: you
should not use (and do not need) an array to solve this. (20 points)
c. Extra Credit: Function Run_out_of_paper: Write a recursive
function that computes when a printer with 10,000 page capacity
(e.g. Printer_Capacity) and initial 10,000 pages Paper_Load will
run out of paper. Assume that each day 5214 pages are being
printed and at the end of the day 50% of the printer’s available
capacity is being loaded back into the printer.
Explanation / Answer
#ifndef LOOKUPFILE_PRINTER_H
#define LOOKUPFILE_PRINTER_H
#include<iostream>
using namespace std;
enum Type {
DOT_MATRIX,
INK_JET,
LASER
};
class Printer {
private:
Type type;
bool status;
int printer_capacity;
int paper_load;
public:
Printer();
Printer(Type type, bool status, int printer_capacity, int paper_load);
Type Get_Type();
bool Get_Status();
int Get_Capacity();
int Get_Load();
int Get_Capacity();
void Input_printer();
void Display_printer();
int Print(int numberOfPages);
int Load(int numberOfPages);
};
#endif //LOOKUPFILE_PRINTER_H
First and second assignment is odne :
for second part i need some input
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.