COP 3540 – Data Structures with OOP



COP 3538 – Data Structures with OOP

Program #1

Due: 16 September 2013 (midnight)

Using NetBeans 7.1 or newer version along with the JDK bundled, you are to write a Java program using OOP principles to accommodate the following functionality

Assignment #1

Objectives:

Provide student with experience building arrays of objects

Provide student with opportunity in doing file input output.

Provide student with exercises in learning UML

Provide student with exercises in Javadoc and its various formats

Provide student with exercises in searching, sorting, and comparisons of key searches and sort routines.

Functionality: This looks like a long program, but much of the code will be discussed in class and is in the book ready for you to tailor to these requirements.

1. Download the States.Fall2013.txt file and include it in your project folder as you have done in the past. Delete ONLY the descriptor lines above the first data line. These lines are to assist you in determining the relative positions of the attributes within each record. Clearly, you need this file to build your array of objects.

2. Build an array of State objects. You are to develop a class named State and create 50 objects of type (class) State – one object for each record (line) from the input file. (You are to use Buffered Reader options and not Scanner). Each State object will have six properties defined individually as ints, Strings, or whathaveyou, as appropriate for each State object. You can see the attributes and the positions they occupy in each input line.

3. Display the array of objects. From main() you are to write code to print the array of objects. You are to have a column header, followed by a blank line, followed by single spaced (one line per object) output. All attributes are to be aligned under their column header: numeric data is always right justified with commas, String data is left justified. Work with samples of student output formatting available on my web page. This is to be a professional looking display.

4. Create an output file: Create program1.states.in.out and include it in your project folder when you submit your project. This file is NOT to appear like the displayed output. It is to consist of only the unformatted data lines (not spaced out; no headers….). The output file, then, will consist of fifty data lines only. You will need this created copy for your input again ahead in Step 6. So ensure it is formatted correctly.

5. Sort the array of objects (Insertion Sort). Using the state name attribute of each object, you are to sort the array using an insertion sort (ascending). Upon completion of the sort, display the sorted objects in the same format as in 3 above. Include a header that says: Array of State Objects Sorted with An Insertion Sort. Follow this with the column header used in 3 above, followed by the data objects themselves, formatted as in 3 above.

6. Sort the array of objects (Bubble Sort). Using program1.states.in.out created in Step 4 above, create another array of objects. Then, using the state name attribute of each object, you are to sort the array using a bubble sort (ascending). Upon completion of the sort, display the sorted objects in the same format as in 3 above. Include a header that says: Array of State Objects Sorted with A Bubble Sort. Follow this with the column header used in 3 above, followed by the data objects themselves, formatted as in 3 above.

Using the array of objects created via the Bubble Sort, count the number of swaps executed in your code. If you swap, count it; if not, don’t. Ship a line (one blank line) and display the total number of swaps on the next line with caption:

“Number of Swaps Using the Bubble Sort on the Array of State Objects was: “ nnnn

7. Sequential Search Given the input search file (State.Fall2013.txt) you are to search the sorted array (use the inserted sort results) to find / not-find each one search argument in the search file using a sequential search. Your search key (from the transaction file) is on state name. For each search key, you are to display the search key, number of probes, and a ‘found’ or ‘not found’ value. (Some of the input search arguments may not match. This is fine and intended. Clearly FL is not a state name; but it is to be used as a state name in searching. You will get a no-hit on this one and a few others. Others are misspelled intentionally.) Best approach is to read search arguments from search file into another array, and use those array elements one by one as search arguments. In this way, you may reuse the array in (5) below and avoid reprocessing the input search file.

Your output should appear as: (example)

Search Results for Sequential Searching

Argument Found Not-Found Nbr of Probes

Puerto Rico X 50

Alabama X 1

Etc.

8. Binary Search. 5. Same as (4) above, but use a binary search. Your results, as above, are to display the search key, found or not found X, and number of probes to find or not find the target. Be certain to skip a couple of lines between the outputs from 7 and the outputs from 8. Note the number of probes (max) can be calculated. Compare your work!!!

UML

You are to include a UML class diagram. You may use Word or Power Point.

No other technology may be used!

Use the examples in your 2551 text. Each class listed in your UML diagram must have attributes listed (name, type). Methods must be shown with visibility indicators, and number /type of arguments plus the return type.

Connect all classes (label the associations). See samples to ensure you are correct.

‘Drag’ your UML design file into your P1 subfolder within your COP3538 desktop folder. It will be included in the zip file to me.

Javadoc

All programming is to be accompanied by appropriate Javadoc.

Each class and each method in each class (object) must have appropriate documentation associated with it.

Appropriate documentation for methods consists of a short description (single sentence) plus any parameters and any return types specified via @params and @return. Each method Javadoc must include an @params and an @returns. If nothing is returned or no params needed, so state: None

Appropriate documentation for classes includes several sentences describing the purpose of the class. Include @author and any other documentation that assists in documenting that particular class. Of course, objects related to this class should be described via accompanying UML diagrams.

The generation of Javadoc is documented on my web page.

You are to zip all files in your P1 as expected and Send them to be via Blackboard Assignment using the same naming conventions as in P0.

Grading

Source Code – 20 points

Indentation and alignment. Scrutinized very closely.

Internal comments – need Javadoc for each method and certainly each class

Scope terminators. Big on this. End of fors, whiles, nested structures, classes, methods…any closing brace…

Overall program structure Should have three or four classes.

Program Design – 30 points

Appropriateness of the objects and their services provided

Interface to objects

Attribute and method visibility

Methods that process the data should be in the same object as the data.

The use of ‘static’ for anything will be closely scrutinized! You may use static variables / static methods for counters and perhaps for I/O in the Main class, although a fourth class for I/O would be better.

UML – 15 points

Correctness, associations, completeness. This means that the classes you identify are correct, that associations are indicated, and that the attributes and methods are documented within the classes.

We will look for visibility indicators; format of UML statements (return type st (not Java)) pg. 254. Include associations. .

Pseudo-Code – 15 points

Include your pseudo-code for your collection class. This is really your main class and should include the array definitions and the methods that access the arrays of objects.

Javadoc – 10 points

Appropriateness and completeness of comments

Must generate Javadoc in prescribed manner. If done incorrectly, will not have the same number of artifacts in the dist folder.

Outputs – 40 points

Accuracy and Format

Skip lines in between displayed numbers for readability.

Include headers / descriptors as you may feel appropriate.

Compliance with the Specifications!!

Program must run correctly to receive a passing grade.Start early and do this a little at a time.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download