Find Jobs
Hire Freelancers

Time Class and Operator Overloading

$10-30 USD

完了済み
投稿日: 3年以上前

$10-30 USD

完了時にお支払い
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
プロジェクト ID: 27876296

プロジェクトについて

5個の提案
リモートプロジェクト
アクティブ 4年前

お金を稼ぎたいですか?

Freelancerで入札する利点

予算と期間を設定してください
仕事で報酬を得る
提案をご説明ください
登録して仕事に入札するのは無料です
アワード者:
ユーザーアバター
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 1日以内
5.0 (9 レビュー)
2.7
2.7
この仕事に5人のフリーランサーが、平均$52 USDで入札しています
ユーザーアバター
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 1日以内
4.9 (72 レビュー)
5.4
5.4
ユーザーアバター
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 3日以内
5.0 (4 レビュー)
2.4
2.4
ユーザーアバター
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 2日以内
0.0 (0 レビュー)
0.0
0.0

クライアントについて

UNITED STATESのフラグ
Lowell, United States
0.0
0
お支払い方法確認済み
メンバー登録日:10月 23, 2020

クライアント確認

ありがとうございます!無料クレジットを受け取るリンクをメールしました。
メールを送信中に問題が発生しました。もう一度お試しください。
登録ユーザー 投稿された仕事の合計
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
プレビューを読み込み中
位置情報へのアクセスが許可されました。
あなたのログインセッションの有効期限がきれ、ログアウトされました。もう一度ログインしてください。