Question
Hey I really need some help asap!!!! I have to take the node class that is in my ziplist file class and give it it's
Hey I really need some help asap!!!! I have to take the node class that is in my ziplist file class and give it it's own file. My project has to have 4 file classes but have 3. The Node class is currently in the ziplist file. I need it to be in it's own file, but I am stuck on how to do this. I also need a uml diagram lab report explaining how I tested my code input and output and more. The uml diagram and summary are most important! Thank you very much, and have a good day. Your help is appreciated.
My project just asks a user for a zipcode then prints the zipcode and it's town and state. Here's the file format for zipcodes.txt if u need it:
Here's how my report has to be:
Assignment Analysis and Design
In your own words, describe the problem including input and output. Briefly describe how you developed your code. Briefly describe what your code does and how it works including anything different or unique or special that you did in your software. If the software is long or complicated, describe how it is organized.
Include a copy of any pseudocode or other design documents you used. If you worked with anyone else, asked anyone for help, or looked anything up, then mention it here. include proper references to source material.
Assignment Code
Include the code for your assignment Unless otherwise directed by the assignment or by your instructor, that will be a zipped copy of your NetBeans project attached to the report.
You can put the report and the NetBeans project all in one zipped folder. In the report, either tell the reader that it is attached file or include the code.
A zipped folder may contain another zipped folder. You can copy the zipped folder for your NetBeans project and your lab report into a folder for your assignment, then zip the assignment folder.
Assignment Testing
Describe how you tested this program to verify that it runs correctly.
Assignment Evaluation
Briefly describe what you learned from this project. What things did you struggle with? what was easy? Give your opinions of the process, including what you liked about the project and any suggestions you have for improving the project.
Here's how the format of the zipcodes.txt that was used for the project:
08001 Alloway Salem County 08002 Cherry Hill Camden County 08003 Cherry Hill Camden County 08004 Atco Camden County 08005
and so on for a lot of zip codes and properties.
Here's my code:
package LinkedListProject; import java.util.Scanner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class linkedListProject {
public static void main(String[] args) {
// creating a scanner to read user input from keyboard Scanner input = new Scanner(System.in);
// creating a BufferedReader to read input file BufferedReader reader;
int code;
String state, town;
// creating an empty ziplist to store zip codes from file
ziplist listOFCodes = new ziplist();
// trying to open the file
try{ reader = new BufferedReader(new FileReader("zipcodes.txt"));
// reading a line
String line = reader.readLine();
// checking in loop if line has been read successfully
while (line != null) {
// converting line to integer, using as zip code
code = Integer.parseInt(line);
// reading next line, using as town
line = reader.readLine();
town = line;
// reading next line, using as state
line = reader.readLine();
state = line;
// reading next line for the next loop
line = reader.readLine();
// creating a zipcodes object and adding to the ziplist object
listOFCodes.addTOList(new zipcodes(code, town, state));
}
//closing file reader
reader.close();
} catch (IOException e) {
//exception occurred, file not found
e.printStackTrace();
}
//looping indefinitely
while (true) {
//asking user for a zipcode
System.out.print("Enter the ZIPCODE you want to find or STOP to exit: ");
//getting zip code
code = input.nextInt();
//checking if zip code is sentinel value
if (code == -1)
break; //end of loop
else {
//searching zipcode and displaying results
listOFCodes.searchZipCode(code);
System.out.print(" ");
}
}
}
}
//zipcode.java
package LinkedListProject;
// zipcodes.java
//class to represent a zipcode
public class zipcodes {
// variable for storing zipcode
private int zipcode;
// variable for storing town and state
private String town, state;
/**
* default constructor doing nothing
*/
public zipcodes() {
}
/**
* parameterized constructor taking initial values for zipcode,town and
* state
*
* @param zipcode
* integer zip code
* @param town
* town name
* @param state
* state name
*/
public zipcodes(int zipcode, String town, String state) {
this.zipcode = zipcode;
this.town = town;
this.state = state;
}
/**
* setter for zipcode
*
* @param zipcode
* new zip code
*/
public void setZipcode(int zipcode) {
this.zipcode = zipcode;
}
/**
* setter for town
*
* @param town
* new town name
*/
public void setTown(String town) {
this.town = town;
}
public void setState(String state) {
this.state = state;
}
/**
* returns the zipcode * @return */
public int getZipcode() {
return zipcode;
}
/**
* returns the town name * @return */
public String getTown() {
return town;
}
/**
* returns the state name * @return */
public String getState() {
return state;
}
/**
* returns a string containing all info * @return */
@Override
public String toString() {
return "Zipcode=" + zipcode + ", Town=" + town + ", State=" + state;
}
}
//ziplist.java
package LinkedListProject; // ziplist.java
/**
* class to represent a list of zip codes
*/
public class ziplist { // Class variables for the Linked List private static ListNode head; private static int totalNodes;
// constructor with no args that initialise things public ziplist() { head = null; totalNodes = 0; }
public ziplist(zipcodes code) { head = new ListNode(code); }
public static int getSize() { return totalNodes; }
public void addTOList(zipcodes zipcodes) { // Check if the list is empty if (head == null) { head = new ListNode(zipcodes); totalNodes++; }
ListNode tmp = new ListNode(zipcodes); ListNode currentNode = head;
if (currentNode != null) {
// starting at the head node to the end. Add the new element after last node while (currentNode.next != null) { currentNode = currentNode.next; }
// Now update the reference for the last node to new node currentNode.next = tmp; totalNodes++; } }
//looks for the specific zipcode in the list and returns the result accordingly public void searchZipCode(int code) { System.out.println("Find code: " + code); ListNode t = head;
for (int i = 0; i < totalNodes; i++) { if (t.data.getZipcode() == code) { System.out.println(t.data); return; } else { t = t.next; } } System.out.println(" The zip code was not found."); } class ListNode { // Declare class variables private ListNode next; private zipcodes data;
public ListNode(zipcodes zipcodes) { data = zipcodes; }
public Object getData() { return data; } } }
//////////////////////////////////////////End zipList.java/////////////////////////////////////////////////////////////////
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started