COP 2551 – Introduction to OOP Program #4 Due: 18 Nov 2009 Using NetBeans 6.7.1, you are to write a Java program using OOP principles to accommodate the functionality articulated below. Assignment #1 Objectives: Provide student with experience building arrays of objects Provide student with opportunity in doing file input and output. Provide student with exercises in learning UML Provide student with exercises in Javadoc and its various formats Provide student with exercises in searching and traversing the array of objects. Functionality: 1. Build array of State objects. . Using States.Fall2009.txt you are to build an array of 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 may cut off the first few lines of information. These are for you to see the relative position and length of each attribute. Data may be in different relative positions than your previous files. So check this out. You are not to alter the data, however, in any way except eliminating the lines prior to the first state data.) Each State object will have six properties defined individually as ints, Strings, or whathaveyou, as appropriate for each State object. Do not use StringTokenizer. Use the substring method in the String class to parse individual attributesyou’re your objects. . 2. Display the Array of State Objects on the Monitor and in an External File. From main() you are to write code to print the array of objects. Write these to your screen via toString or some display() method in your State class. Also, you are to write these objects to an external file called States.print.txt. See my slides on I/O on my web page for examples. On the displayed output (screen), you are to have a column header, followed by a blank line, followed by single spaced (one line per object) output with data lined up underneath the tag in the column header. We will discuss. For the file output, only write the records and omit the printed header line.. 3. Scan and Develop Totals Using the array of State objects, you are to examine each State object and accumulate data. At the end of this scan, you are to print out a header that says Population By Region (left justified) and underneath this, you are to print the number of states and the average population of states in that region. (See data: regions are numbered 1 through 6). Your format for these detail lines should appear as: Region and Average Population per State New England 6 5,321,123 (note the spacing; use tabs) At the end of printing these lines, you are to print: Population of the United States: StateCount 50 301,222,333 (or whatever you add up to) 4. Search Requirement. Using a Scanner object, you are to prompt me interactively to submit a state name to you. You are to search through your array of state objects again and identify ‘hits’ or ‘no hits.’ (match or no match…) If a hit (match) is encountered, you are to display: Hit for input: <input State name > <advance to next line> State Particulars are: <State name, State Region> Ensure these are spread out via tabs or suitable spacing… There is to be a header prior to any displaying of course. It should read: Search Engine Results (left justified). Skip a line (blank line) before you start printing the Hit for input line and others. These outputs (detail results from the search) are to be single spaced. Loop so that I may repeatedly test your search engine. Ask if I want to search more, to which I can respond Y or y and continue until I enter a N or n. At the end of searching (when I enter an N or n), you are to display the number of successful searches and the number of unsuccessful searches according to the format: <blank line> Summary Statistics: Number of Successful Searches: <an integer> Number of Unsuccessful Searches: <an integer> (Ensure there are spaces between your text and the integers you display.) Design: Architectural and Detailed (UML and pseudocode) You are to include a UML class diagram. You may use only 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 indicator, and number /type of arguments plus the return type. Connect all classes (label the associations). Use UML format not Java. See previous lectures and your text for examples. ‘Drag’ your UML design into your P4 subfolder within your COP2551 desktop folder. It will be included in the zip file to me. All other files should also be included in this folder which also must include the initial States file too. Javadoc All programming is to be accompanied by appropriate Javadoc. ALL methods are to have Javadoc comments preceding them (in your source code). Appropriate documentation for methods consists of a short description (single sentence) plus any parameters and any return types specified via @params and @return. Javadoc generation: From the Project window pane, right click on the projectname at the top of the pane. Select Properties (last choice in the drop down). Select Documenting Select Document Additional Tags – Author Click OK All Javadoc will be generated and moved to your program folder and placed into a subfolder entitled ‘dist.’. (What a deal!) Do this at the very end of your programming effort so as to ensure all comments are captured. Grading Source Code – 30 points Indentation and alignment Internal comments – need Javadoc for each method and certainly each class Scope terminators big on this. End of fors, whiles, nested structures, classes, methods… Overall program structure Should have three or four classes. Program Design – 30 points Architectural Design (UML) (15 points) Appropriateness of the objects and their services provided Interface to objects Attribute and method visibility Detail Design – Pseudocode (15 points) Each method (non-trivial ones) are to have pseudocode to reflect the logic to be implemented. You should build these pseudocode text efforts in a single file called pseudocode.progrma4.txt. Be certain to follow the rules discussed in class and shown via examples. Loops, indentation, scope terminators are essential. You only need to provide pseudo-code for all the methods in your State class. 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 – 30 points Accuracy and Format Skip lines in between displayed numbers for readability. Include headers / descriptors as you may feel appropriate. Needs to be professional looking……………… Look for major functional capabilities: allocate these to appropriate objects (where the data is) as much as possible. Build an array. Verify!!! print the array of objects Verify Write to the output file Verify! search state arrays ensure you are reading in what you think you are reading in… print results at end, print summary information. etc. Program must run correctly to receive a passing grade. Start early and do this a little at a time.
Pages to are hidden for
"COP 3540 � Data Structures with OOP"Please download to view full document