[Solved] SOLVED:Lab 2 — C++ Classes soln

30 $

File Name: SOLVED:Lab_2_—_C++_Classes_soln.zip
File Size: 310.86 KB

SKU: [Solved] SOLVED:Lab 2 — C++ Classes soln Category: Tag:

Or Upload Your Assignment Here:


In this lab, we will implement a simple C++ class named Time. It represents all possible times in a 24-hour period, including hours, minutes and seconds. An immediate representation issue is how to handle morning (am) and afternoon (pm) times. We could have a separate bool indicating whether the time is am or pm. It is easier, however, to represent the hours in military time. This means that the hours of the day are numbered from 0 to 23, with 13 being 1 pm, 14 being 2 pm, etc. Your notes from Lecture 3 with the example Date class will be helpful in completing this lab. Checkpoint 1 In the first checkpoint you will get started by implementing the initial class design, several member functions, and a simple main program to test your class. The instructions below describe how to build your executable using from the command line using g++ or clang++ using Cygwin or UNIX terminal. Even if you plan to use Visual Studio or another IDE for the bulk of your work this semester, you are required to also show that you can successfully build and run this lab using g++ from a terminal on your own machine. • Make a subfolder inside of your Data Structures labs directory for lab 2. Create 3 new empty code files named time.h, time.cpp and main.cpp. Note that in C++ the name of the header and implementation file are not required to exactly match the name of the class, but it is good coding style to do so. • Begin work on time.h. Within the file, declare a class called Time. Follow the form and syntax of the Date class from Lecture 3. Read the syntax carefully (such as the semi-colon at the end of the class declaration). Add private member variables for the hour, minute and second. In the public area of the class, declare two constructors: one, the default constructor, should initialize each of the member variables to 0; the other, having three arguments, accepts initial values for the hour, minute and second as function call arguments. Declare member functions to access the values of the hour, the minute and the second (three different member functions). It will be crucial for Checkpoint 3 to make these const. (Recall: a const member function can not change the member variables.) Don’t write the body of any of the functions in the time.h file. Save all the implementation for the time.cpp file. • Switch to working on main.cpp. Be sure to add code to #include “time.h” in addition to including #include

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED:Lab 2 — C++ Classes soln
30 $