Netbeans:Java Write this code. : well documented please. Text file name to be us
ID: 3667127 • Letter: N
Question
Netbeans:Java Write this code. : well documented please. Text file name to be used: Statedata.txt
Last programming assignment:
three classes
Your task is to create software similar to the last programming assignment implementing a list of states, but the list should be implemented using a linked list instead of an array. This project will require a new StateList class which uses a linked list instead of an array, and a new class for a ListNode If properly implemented, you should not need to change the project class - it should work with a list class whether that list is implemented with an array or a linked list. The internal details of the data structure should not affect the user's view of operations from outside the data structure. In other words our classes should be encapsulated, so a StateList class has methods that define the user's view of the class. Those methods should provide the same functionality to the user no matter what the internal mechanisms of the methods are. That functionality is defined by the method's name and parameters, its returned values, and any messages it prints The main method should simply call the other methods in the class to show that they work Each class should be in its own file, within the same package in the same NetBeans project, just as in the previous assignmentExplanation / Answer
package stateproject;
/* Class Node */
public class ListNode extends ListData
{
protected ListData d;
protected ListNode link;
/* Constructor */
public ListNode()
{
super("","",0);
link = null;
}
/* Constructor */
public ListNode(String nam, String c, int p,ListNode n)
{
super(nam,c,p);
link = n;
}
/* Function to set link to next Node */
public void setLink(ListNode n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(String nam, String c, int p)
{
d=new ListData(nam, c, p);
}
/* Function to get link to next node */
public ListNode getLink()
{
return link;
}
/* Function to get data from current Node */
public String getData()
{
String msg=Name+ " "+Capital+" "+Population;
return msg;
}
}
/////////////////////////////////////////////////
package stateproject;
public class ListData {
String Name;
String Capital;
int Population;
ListData(String n, String C, int p)
{
Name=n;
Capital=C;
Population=p;
}
public String getName()
{
return Name;
}
public void Display()
{
System.out.println(Name+ " "+Capital+" "+Population);
}
}
////////////////////////////////////////