Sale!

CS 2401 Homework Assignment 1 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (5 votes)

Operators as Members
Those of you who took CS2400 last semester may of had the experience of creating, in week 12 or 13, a class called MyTime. I have made a version of this class available in ~jdolan/cs2401/hw/hw1, which you can copy to your own directory with the cp command. 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. The math and Boolean operators should use const to protect the object which is being used as the left-hand operand.
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, using the overloaded input operator, and a scalar, and then see all the math and 2 of the Boolean operators performed on those numbers.
Once you are done writing this you can create a sample of your output by typing
script results.txt <= this creates a file that will record all your interaction with the terminal a.out <= this runs your program – do the interaction with the program until the end ctrl-d <= this stops the script, a history of your interaction is now in the file results.txt (Another way to do this is to run your program is to run it in a terminal window, highlight all of your program interaction and then use copy-paste to put it into a text file in whatever editor you have been using for your code.) 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.) See schedule for due date.