Description
The list using dynamic storage to store computer’s information for a computer laboratory. Given the
respective classes as follows:
public class Computer
{
private int serialNo; //computer identification
private String brand; //brand name
private int year //year of buying
private double price //buying price
//Normal constructor
//Getter
}
public class ListNode{
private Object obj;
private ListNode next;
:
:
}
public class List
{
private ListNode firstNode; //reference to the first node in the list
private ListNode lastNode; //reference to the last node in the list
private ListNode currNode; //to traversal purpose
:
:
publicList();
public void insertAtFront(Object);
public void insertAtBack(Object);
public void insertAtAtMiddle(Object);
public Object remove(int);
public void searchComputer(int);
public int countComputer(double);
}
a) Write all definition functions for the above operation to do the following tasks:
i. To insert a new node (computer’s information) at the front/back/middle of list. The information
is given by a parameter. If the information existed in the list, you don’t have to insert the node.
(NOTE** Every computer has a unique serial number identification)
ii. To remove a node from the list based on the serial number of the computer. Computer serial
number is given by a parameter.
iii. To print the output of computer’s information based on the searching index (the serial
number). Computer serial number is given by a parameter.
iv. To count and return the number of computers which exceed a certain amount price. The
amount is given by a parameter. This method also will print the output of brand code and year
of buying which computers fulfill the above criteria.
b) Write an application program by implementing a menu selection to do the following tasks.
i. Insert a new node into list. The computer to be inserted can be at the front, at the back and at
the middle of the list based on the user selection.
ii. To delete any node from a list based on serial number of the computer
iii. To print the output of computer’s information based on the searching index
iv. To count and return the number of computers which exceed a certain amount price