Find Jobs
Hire Freelancers

Time Class and Operator Overloading

$10-30 USD

Completed
Posted over 3 years ago

$10-30 USD

Paid on delivery
Write the following overloaded operators, which have prototypes already written in Time.h and empty definitions (that you must complete) in [login to view URL]: • Input/output operators: << >> • Comparison operators: == != < > • Arithmetic operators: + - += -= • Increment operators: ++ as both pre- and post-increment Operator specifications Input/output Both the input and output operators should handle times entered in the form h:mm _M or hh:mm _M, where • h or hh = # of hours, using 1 or 2 digits • mm = # of minutes, always using 2 digits • _M = AM or PM Examples of valid times: 7:30 PM, 12:22 AM, 9:09 PM. Comparison Each comparison operator tests the relationship between two Time objects, returning a boolean value indicating if the specified condition is true or false. As noted above, the conditions being tested are equality (==), inequality (!=), less than (<), and greater than (>). Arithmetic The arithmetic operators perform addition or subtraction between two Time objects as follows: • When adding two times, take the first time and advance it by the number of hours and minutes specified in the second time. • When subtracting one time from another, take the first time and move it back by the number of hours and minutes specified in the second time. Keep in mind that a time after noon (12:00 PM) is 12 hours later than the same time before noon. The following examples demonstrate the desired arithmetic: • 3:35 PM + 12:17 AM = 3:52 PM (add 0 hours, 17 minutes) • 8:00 AM + 7:06 PM = 3:06 PM (add 19 hours (since 7 PM = 12 + 7 = 19 hours), 6 minutes) • 4:15 AM - 3:20 AM = 12:55 AM (subtract 3 hours, 20 minutes) • 1:15 PM - 3:20 PM = 9:55 PM (subtract 15 hours, 20 minutes) The difference between the two addition operators is the += operator stores the sum in the calling object, while the + operator creates a new object to store the sum and returns a copy of that new object, without modifying the calling object. In other words, the following two statements calculate the same sum (T2 + T3), but the first one stores that sum in T1, while the second one stores the sum in T2: T1 = T2 + T3; T2 += T3; // shorthand for T2 = T2 + T3; The difference between the - and -= operators is similar. Increment The pre- and post-increment operators are similar to the add operations, but, as unary operators, each of them adds a single minute to the time stored in the calling object. Recall that the difference between pre- and post-increment operators is essentially that the pre-increment operator changes the calling object and then returns a reference to it, while the post-increment operator copies the calling object and returns its original value after changing the original object. Hints Suggested order I'd suggest writing these operators in the following order: • Output operator (<<): Testing every other operator is easier when you can print the result, and it's easy to declare and initialize Time objects • Input operator (>>): This operator is only used in the first two test cases--we don't combine input tests with any other operator tests--but moving on to this one is a logical extension of the output operator. • Comparison operators (==, !=, <, >): All of these operators are similar, and checking how two Times compare to one another is relatively straightforward. • Arithmetic operators (+, -, +=, -=): Understanding how to correctly add and subtract Time objects is the hardest part of this assignment, in my opinion. (Remember, I couldn't get the advance() function right the first time!) There are a couple of special cases to account for, as described below. I recommend handling the simple + and - operators before the augmented assignments += and -=. • Increment operators (++): The increment operators are definitely simpler than the add and subtract operators, but you have to understand addition to write these correctly
Project ID: 27876296

About the project

5 proposals
Remote project
Active 4 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi! I am an expert in C, C++ and data structures. I would be easily able to help you regarding any task related to them. Kindly message me to discuss more details. Thank you!
$50 USD in 1 day
5.0 (9 reviews)
2.7
2.7
5 freelancers are bidding on average $52 USD for this job
User Avatar
Hi there, I am expert in C++ and I can do this task today. Feel free to inbox me any time. Thank you.
$50 USD in 1 day
4.9 (72 reviews)
5.4
5.4
User Avatar
Hello, Hope this message finds you well, I checked your details and I believe that my experience is what you are looking 4. I have been working on similar projects for the past eight years, and I have the essential skills including; C++ Programming I will prove to be of great help to you. SEND MESSAGE/CHAT, so that discuss more on the details including budget and deadlines… Please REMEMBER to; Wash your hands frequently, Maintain social distancing, Avoid touching eyes, nose and mouth..., Practice respiratory hygiene, Stay home and if you feel unwell seek medical care early. Regards, BrainCenter Inc
$100 USD in 3 days
5.0 (4 reviews)
2.4
2.4
User Avatar
Hello! I'm a professional programmer in computer science. I look forward to the best possible time and on a low budget to solve your informatics tasks, projects, and tasks. Are you stuck in the middle of an IT task, a project, and a task? Do you need support in challenging tasks, projects, and activities of computer science? I will be there for you. *****Please must contact me before placing the order for quality work**** I will help you with those courses: • Programming Fundamentals • Object Oriented Programming • Database Programming • Operating Systems • Human-Computer Interaction • Data Structures • Software Engineering • Web Development • Android Development • Artificial intelligence / Data Mining #Programming_Languages 1- C++/ C# 2- OOP 3- PHP 4- SQL 5- Andriod + IOS 6- Java 7- Python More, I will prepare for: 1- Quizzes 2- Assignments 3- Exams ORDER NOW! ✔︎Fast Delivery 100% sure ✔︎Excellent Customer care service ✔︎100% Quality assurance
$30 USD in 2 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Lowell, United States
0.0
0
Payment method verified
Member since Oct 23, 2020

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.