CSC3002 23fall Assignment 3
CSC3002 23fall Assignment 3
CSC3002 23fall Assignment 3
Requirements Please finish sumArray, findLargest and findSmallest functions in the file GymJudge.cpp.
DO NOT modify the main() part, which is for testing unit.
In & Out Your program should accept input values until the maximum number of judges is reached or the
user enters a blank line.
If the number of input values is less than 3, prompt a error message. If a score that is out of range is received,
such score will not be counted and a error message will also be prompted. The processing steps are in the
function readScores(), which you should not modify but are highly recommended to read.
1
Problem 2
Part1:(Exercise 12.4, Points: 15)
Problem Description Design and implement a class called IntArray in intArray.cpp that implements the
following methods:
• A constructor IntArray(n) that creates an IntArray object with n elements, each of which is initialized
to 0.
• A destructor that frees any heap storage allocated by the IntArray.
• A method size() that returns the number of elements in the IntArray.
• A method get(k) that returns the element at position k. If k is outside the vector bounds1 , get should
prompt the message:"ERROR: Index range out of bounds!".
• A method put(k, value) that assigns value to the element at position k (directly assign, not insertion).
As with get, the put() method should call error with the same message if k is out of bounds.
Use int[] instead of wrapping an exiting vector<int>.
In & Out Two integers should be input to test the functionality of this program:
Position meaning
0 index of the task
1 size of array
In & Out Two integers should be input to test the functionality of this program, with the same meanings
of those in Part 1. The index of the task = 2 in this part. Other test input modes are the same as those in
Part1.
Please see out/p2_2.txt for output format.
2
Part3:(Exercise 12.6, Points: 5)
Problem Description Implement deep copying for the IntArray class from P2Part1 and P2Part2.
The following functions should be completed in this part:
• A function that copies the data from the src parameter into the current object. All dynamic memory is
reallocated to create a "deep copy" in which the current object and the source object.
void IntArray :: deepCopy ( const IntArray & src )
In & Out Two integers should be input to test the functionality of this program, with the same meanings
of those in Part 1. The index of the task = 3 in this part.
Other test input modes are the same as those in Part1.
Please see out/p2_3.txt for output format.
About P2
• Please complete all the functions included in the problem descriptions, other wise your program will be
deducted even if the OJ running results go well.
• In all test cases for this problem, size of array n is a non-negative integer.
• Pre-test cases on the OJ platform are test case of part1, part2, and part3, respectively.
• DO NOT modify the main() part, which is for testing unit.