All of the work in this project is my/our own! I/We have not left copies of my code in public folders on university computers. I/We have not given any of this project to others. I will not give any portion of this project to others taking this class. I realize that the penalty for turning in work that is not my own can range from an "F" in the class to dismissal from Trinity University.
Print Name __________________________ Time Required = ______.____ Hrs.
Signature __________________________ (pledged)
Team Mate:
Print Name __________________________ Time Required = ______.____ Hrs.
Signature __________________________ (pledged)
1] Copy your Stack class to a file called IntArray1.java
2] Replace every occurrence of top with actNo.
3] We are going to create our own Integer Array class. You may not use any of the built in Java Array or Vector processing tools for this lab.
4] Your private data is to be
private int [] info; private int actNo; private boolean sorted; private int max;
5] Write the constructor
IntArray1(int maxElements)
which
creates and info array of maxElements + 1 integers
initializes the actNo to 0 [you are to place the first value in element[1] of the array
initializes the max to maxElements [do not allow to be negative]
initialize sorted to be false.
6] Write functions
void Display (); void Display(String message)
which
display the optional message
display a nice graphical output in the form
Message
|----------------------------------------------------|
3 |
1232 |
|----------------------------------------------------|
2 | 331 |
|----------------------------------------------------|
1 |
5555 |
|----------------------------------------------------|
actNo = 3
max = 5
sorted = false
Write function
void QuickAndDirtyDisplay (message);
which
display the optional message
displays the actno, max, and sorted flags
displays the numbers in 8 character blocks, ten to a line
Message
actNo = 22
max = 500
sorted = false
12 233
1 13
28 1111
122 2
211 21
332 213
221 4223
8 1
22 333
111 221
111 18
6] Write function // use the one from your stack program - modify slightly
void Resize (int changeAmount);
which
alters the size of the array, either up or down, by the changeAmount
do not ever make the array smaller than the actNo and loose data
do not ever make the array <= 0 in size
7] Write function
void FillRandom (int noToFill, int low, int high);
which
places noToFill random integers, in the range low to high, into the info array starting with element 1
make the array bigger if necessary
do not make the array smaller
8] Write function
void FillFromFile (String FileName);
which
opens the file
places the values from the file into the info array [don't know how many there are] starting with element 1
make the array bigger if necessary
do not make the array smaller
9] Write function
int SequentialHigh ();
which
explicitly returns the highest value in the unsorted array
10] Write function
int SequentialLow ();
which
explicitly returns the lowest value in the unsorted array
11] Write function
double Mean ();
which
explicitly returns the arithmetic mean of the elements in the array
12] Write function
int Sum ();
which
explicitly returns the arithmetic sum of the elements in the array
13] Write function
int TestIntArray1 ();
which
fully tests each of the functions above
your test module might start something like :
public static void TestIntArray1()
{
System.out.println("====================== Test Default Constructor ===========================");
IntArray1 nos1 = new IntArray1();
nos1.Display("Contents of nos1");
System.out.println("====================== Test Normal Constructor ============================");
IntArray1 nos2 = new IntArray1(4);
nos2.Display("Contents of nos2");
IntArray1 nos3 = new IntArray1(-4);
nos3.Display("Contents of nos3");
System.out.println("====================== Test Sum ===========================================");
nos1.info[1] = 5;
nos1.info[2] = 15;
nos1.info[3] = 10;
nos1.actNo = 3;
nos1.Display("Contents of nos1 = 5 15 10 ");
System.out.println("Sum = " + nos1.Sum());
// You Do
}
14] Document each and every module for
javadocs
What To Turn In
Staple one copy per team of the following in this order
A] Copy of this assignment sheet. Using an ink pen, print your name and sign this lab at the top.
B] A copy of IntArray1.java
C] A copy of the output from your program
D] Make a copy of your workspace. Call the copy IntArray1
E] Place a copy of your workspace in folder IntArray1 on my drive /users/thicks/1321-HW/username