CS2401 Lab Assignment 1 Operators as Members


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (4 votes)

In ~jdolan/cs2401/labs/lab1, I have made a version of a class called MyTime available to you. You can copy to your own directory with the cp command (cp ~jdolan/cs2401/labs/lab1 . The dot is significant), or copy it from Blackboard. In this example you will see that I have implemented four of the arithmetic operators, two of the Boolean operators and the input and output operators. They have all been implemented as friends.
Your assignment is to implement all of the operators without using friends. For the Boolean and arithmetic operators you should do this by making the operators members of the MyTime class, and for the I/O operators you should do it by writing input and output functions in the class that do the job of the operator, and then have the operator call that member function. I have included the prototypes for the input and output functions in the MyTime class. The math and Boolean operators should use const to protect the object which is being used as the left-hand operand as well as the object that is passed in.
I have also asked that you combine the two constructors into a single constructor by using default arguments.
When you are done you should write an application that allows the user to enter two times and a scalar, and then see all the math and at least one of the Boolean operators performed on those objects.
Run the script command by typing script lab1output.txt, running your program with your test input, and then ctrl-d to quit.
Submission is done by attaching your completed program files and the script file to the Assignment on Blackboard. (To do this you click on the name of the assignment and then look for the “Browse My Computer” button.)
Grading Rubric:
Each of the nine operators properly overloaded as non-friends = 2 points each (18 points total)
Failure to use const appropriately = -1/2 point per instance
The constructor altered to use default arguments = 2 points
Main which tests all the operators = 10 points