CPT106 C++ Programming and Software Engineering II
Indiv idual Project Fundamental of class and object
Project Number 2 Contribution to Overall Marks 20% Release date 1 April 2023 Submission Deadline 10 M ay 2023, 23:59
How should the work be submitted? SOFT COPY ONLY ! (MUST be submitted through Learning Mall so that we can run your programs during marking.)
Assessment Overview This assessment aims at testing some basic concepts of C++ programming and coding in the software development environment (Visual Studio ). To distribute the workload of the individual project more evenly throughout the whole semester, we divided it into 3 smaller individual projects for you to complete separately. This is the second individual project.
What should be submitted? Only your C++ source code file (,cpp) should be submitted to Learning Mall (LM). Your grade will also be given through LM. There are several step s for you to note :
- You should create a solution named “ CPT106Solution ”.
- Create a project named “Project 2 ”.
- Create a CPP file “MyDate.cpp” to define the class of MyDate .
- Create a CPP file “SubDate.cpp” to define the class of SubDat e.
- Create a CPP file of “123456.cpp” ( 123456 is your student ID )
- Define a main function in “123456.cpp” to test all the functions of two classes and print out results.
- Include clear comments in your code to make it easy to understand.
- Only submit the cpp file s to the LMO . For example, “123456.cpp” , ”MyDate.cpp” and “SubDate.cpp” in “Project 2 ” should be submitted.
- ALL programs MUST compile and run in Visual Studio 2013 /2016/2019 /2022.
Write a C++ program that can perform the following:
- Create a class MyDate to represent a date like follows : 25-JAN-2016 The class contains three data members, denoting the year, the 3 -letter abbreviation of the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) and the date (Note that it is assumed that, for this assignment, Feb. has 28 days.). a. Define constructors and destructors of this class b. Define members to return the date, year, month and day, respectively. c. Using “operator overloading” to realise the following tasks: 1) Define the assignment operator “=” to assign the value of one Date object to the other . 2) Define the comparator “>” “<” and “==” to compare two dates. 3) Define the unary sign “++” to add one day to a date object . 4) Define the subtractor “- ” to subtract days from a date object and return a new date object.
- Create a new subclass SubDate , which inherits from the class MyDate and represents a new date like follows: 25-JAN-2016 16:23:18 a. Define new data members of the subclass to represent the hour, minute and second. b. Define constructors of the subclass. c. Define members to return the date (day -month- year HH:mm:ss), time (HH:mm:ss), hour, minute and second, respectively. d. Define the subtract or “-” in the subclass to return the number of days between two MyDate objects. For example: MyDate d1(2016, JAN, 25), d2(2016, JAN,18); /two MyDate objects/ int days=d1 -d2; /days=7/
- In the main function, you should test these two classes following the requirements below: Requirements: a. Create objects of these two classes in your main function. b. The value of objects should be inputted from the keyboard, c. Test all the function members of the two classes in the main function, and print out the results of these function members. Marking Scheme MyDate class definition 30% (2% for each member in the class ) SubDate class definition 40% (4% for each member in the class) Comments 5% Main functions 5% Correction & Robustness 20% Project 2 (100)