Due: Tuesday September 26, 5:30 pm
At many universities students pay for their printing or photocopying using a copy card. The student purchases credits which are recorded electronically on the card. Then, each time a page is printed the card is charged for that page. The student can also ask the printer or copy machine to show how many unused pages are still on the card.
The java class PrinterCard models the behaviour of one of these printer cards. Download this class and read it. You will also need to download AssignmentOne.java which contains the shell of a main method for your assignment.
AssignmentOne
class and the PrinterCard
class.
AssignmentOne.java
contains
only comment statements divided into Part One and Part Two.
After each comment in Part One, add a single java
statement as directed by the comment.
You have x pages remaining.Except for
x
which will be replaced by an integer, you must print
precisely these words including
the capital Y, the period at the end of the sentence and the spacing:
one space before the number, and one space after. In addition to looking at
your program, we will be marking your output automatically and any output that isn't exactly
as specified will receive a zero.
You must use calls to getBalance()
to complete this step in the assignment.
PrinterCard.java
print()
had to be called 100 times. To improve
the interface of the PrinterCard
class, add another public method called
printMultiple
which has a single integer parameter representing the number of
pages to print. Complete the body of this method and be sure to give it
a method comment. Notice that print()
doesn't check if the card actually
has any available credit. It goes ahead and prints and deducts the page
even if that sets the credit to a negative value. printMultiple
should
have the same behaviour. Later in the course we will learn how we could do
better. Don't change anything else about the PrinterCard
class.
AssignmentOne
, add a single Java statement as
directed by the comment, together with the necessary statements
to print the balance of the card in the specified form (as
explained in point 3 of Part One).
AssignmentOne.java
and your improved PrinterCard.java
for marking.
Check the rules for submission carefully so
you don't get a zero for a silly error (like
submitting to the wrong directory, or with the wrong filename, etc.).