JMU
Programming Assignment 1


1 Overview: For this assignment you must implement a Vector class. In the context of this assignment, a Vector is, essentially, a point in n-dimensional space. That is, a Vector has n components, each of which is a double. Note that, in the context of this assignment, a Vector is not a "resizable array". That is, in the context of this assignment, a Vector has a fixed size.

This assignment is both about vector arithmetic and about C++. With regard to the former, you must implement various operations. With regard to the latter, you must use return by reference, operator overloading, exceptions, and initializer lists.

2 Detailed Specification: The detailed specification/design for the Vector class is available on-line:

Vector ( Design )

3 Help with Initializer Lists: The begin() method returns a pointer to the first element of an initializer list. So, in the following example, values points to the first double (in the array of double values) that is associated with v.
void doSomething(std::initializer_list<double> v)
{
    const double*  values;

    values = v.begin();

    // Work with the array
}
4 Unit Testing: You must write a driver to test your implementation. Your driver must include at least three test cases for each method/operator. Some methods/operators (e.g., those that throw exceptions) may require more test cases.

At this point in the semster, you must use a testing methodology that is, admittedly, awkward. Specifically, your driver must generate the expected output and the actual output for each test case, and you must visually compare the two. The output must be formatted as follows:

For example, one test case for the function Vector operator*(double k, const Vector& a) might look like:

  Vector operator*(double k, const Vector& a)
  Test 1
  Multiplication by a positive constant
  Expected Output:
 -     -
|  5.00 |
|  8.00 |
|  3.00 |
 -     -

  Actual Output:
 -     -
|  5.00 |
|  8.00 |
|  3.00 |
 -     -
  
5 A Development Strategy: Think carefully about how you should proceed, before you start writing and code. Obviously, you will need to make sure that your constructors are working properly before you can move on to any other methods/functions. Less obviously (since you may not have ever overloaded the assignment operator before), you will need to make sure that the assignment operator is working before you can move on to any other methods/functions. In addition, you will probably want to implement the relational == operator fairly early in the process.

It is strongly recommended that you design, implement, debug, and test one method/function at a time.

6 Submission: In addition to the normal materials, your submission must include your driver and the hardcopy output from your driver.
7 A Special Note About Collaboration on this Assignment: You may share code from your driver (only) with other students. However, if you include code in your driver that you did not write you must include a comment (for each test case) that credits the source. In either words, you may form a team to create test cases (to reduce the burden on any individual but still ensure that your code is adequately tested).
8 Grading: Your implementation must work correctly for you to receive credit for this assignment.

Copyright 2014