Uploaded by jeff123

COEN 244 Assignment 1: C++ Invoice & Employee Classes

advertisement
COEN 244 (Fall 2025) - Assignment 1 Description
Submission
The submission must be through Moodle on the submission link for Programming
Assignment 1. Email submissions will NOT be accepted. All cases of plagiarism will be
reported to authorities as per Concordia’s plagiarism policy.
Create [SID_1]_[SID_2]_A1.zip (.gz, .tar, .zip are acceptable. .rar file is NOT
acceptable) file contains a folder named with your student ID. This folder contains all
the source code only for the assignment.
Problem Statement
Problem 1 is from the textbook exercise 3.10.
Task 1.1 address the requirements in above problem statement. The test program
should follow the unit testing structure introduced at the lecture demos. (A reference
example is on the “Summary and reference” web page on Moodle and the workshop
exercises) (20 points). The constructor should use member initialization list.
Incrementally, we develop the Invoice class with the following extra specification.
Task 1.2 add the copy constructor of class Invoice. The constructor should use
member initialization list. (5 points)
Task 1.3 add the destructor of class Invoice. (5 points)
Task 1.4 define a public member function called clone() that returns an Invoice object
with the identical values of the current Invoice object. (5 points)
Task 1.5 define a public member function with overloaded form of clone (const Invoice
&) that returns an Invoice object with the identical values of the pass-by-reference
Invoice object. (5 points)
Task 1.6 write a test program to demonstrates class Invoice’s capabilities defined in
Task 1.2 – 1.5. The test program should follow the unit testing structure introduced at
the lecture demos. (A reference example is on the “Summary and reference” web page
on Moodle.) (10 points)
The main() function should follow the assertion format to print out “pass” or “fail” for
each unit test. For example,
Finally, it should print out a statistics as “ m / n pass and k / n fail ” given the runtime
unit test output, where m is the number of pass cases and k is the number of fail cases,
and n is the number of total unit testing cases.
For example, if 5 total number of test cases are invoked in the main() and 5 cases
pass. The program should print out “5/5 pass and 0/5 fail”.
Problem 2 is from the textbook exercise 3.11.
Task 2.1 add the copy constructor of class Employee. The constructor should use
member initialization list. (10 points)
Task 2.2 add the destructor of class Employee. (10 points)
Task 2.3 address the requirements in the 3.11 and Task 2.1 and 2.2. The test program
should follow the unit testing structure introduced at the lecture demos. (A reference
example is on the “Summary and reference” web page on Moodle.) (20 points)
Checking the “if the monthly salary is positive or not and setting the value to zero” can
follow the example of class Time in the lecture demos.
Task 2.4 Write a new test function called double testMaxEmployeeSalary(). Create an
array of Employee objects with different salary values (at least 10 objects). This
function returns the maximum salary value among all the Employee objects. The
main() function should invoke testMaxEmployeeSalary () in an assert form to print out if
the test passes or fails. (20 points)
Assignment Marking Rubrics:
Level
Class Program
Correctness
(60%)
5
Unit test
function
program
correctness
(20%)
All requirement addressed, programs
run without errors in validation testing.
Report of Design
Quality
(15%)
Report of
Discussion
Quality
(5%)
Design has good
rationale and of
clarity.
Design has good
rationale but miss
minor details
The
discussion
is precise.
The
discussion
is
reasonable
but could
be more
precise.
The
discussion
is not
relevant.
Missing
discussion
Missing
discussion
4
Missing 1 or 2 requirements, the rest of
the function runs without errors.
3
Missing 3 requirements, the rest of the
function runs without errors.
Design has a
couple of flaws
and errors
2
Missing more than 3 requirements, the
program didn’t run properly.
Missing majority of requirements, the
program didn’t run properly.
Design has too
many flaws
Missing the
design
1
Download