This website is preserved for historical and scholarly reference and is no longer actively maintained.
CpSc 210, Section 1
Assignment 4
14 February 2002
Due: Thursday, February 21 at 11:59 p.m.
Not accepted late.
Total point value of assignment: 100 points
This assignment is to be done INDIVIDUALLY.
Create a directory, A4, which will contain all parts of this assignment.
(In this assignment the directory A4 will contain a file
named Matrix.java.) The class will be named Matrix.
Assignment: Modification of Problem 3.10 on page 48 of Java Structures
Finish the two-dimensional Vector-like structure Matrix. (You may
simply add to Bailey's code for the Matrix class. Each element of the
Matrix is indexed by two integers that identify the row and column
containing the value. Bailey has not provided the following methods,
which you need to supply. You may copy Bailey's matrix class at
http://www.mhhe.com/engcs/compsci/bailey/source/Matrix.java
and add your own methods. You should, however, carefully check
Bailey's code for errors. Especially check his Assert statements
for errors. Correct any of Bailey's errors. (You are warned.
If your code gives errors because of his errors, you will lose
points.)
The four methods needed are:
public boolean equals ( Matrix other )
// post: returns true if this contains identical information
// to other; otherwise, returns false.
public void addRow ( )
// post: a row of null entries is appended to the matrix
public void addColumn ( )
// post: a column of null entries is appended to matrix
addRow and addColumn add the new column and row at the end of the
current collection of rows/columns the same way that addElement adds
the new item to the end of a Vector.
Your Matrix should contain Objects of any type, such as Integer,
Character, Boolean, or even Vector. Do not assume that the Matrix
will contain only Strings.
You will need to import structure.Assert.
You will also need to import either structure.Vector or java.util.Vector.
Input:
Initialize variables in your test program (main).
Output:
Print your name, the assignment number, and a short description
of the assignment. Use the System.out commands.
Output should be contained in your test program (main).
Your class will also be tested with other test program(s).
Other requirements:
Follow the style standards to be found on your instructor's
web page for CPSC 210.
Submit your program using the handin command. There is a link to
the handin description on your lab page (www.cs.clemson.edu/~lab210).
Grading rubric:
Required documentation 10 pts.
Style standards 10 pts.
The program compiles without error. 10 pts.
If the program does not compile, no further points will be awarded.
Correct Methods:
equals 20 pts.
addRow 20 pts.
addColumn 20 pts.
Elegance of code 10 pts.