Anda di halaman 1dari 2

public class COMPUTER

{
int serialNo;
String brand;
int year;
double price;

public COMPUTER(){}

public COMPUTER(int sN, String b, int y, double p)


{
serialNo = sN;
brand = b;
year = y;
price = p;
}

public int getSerialNo() { return serialNo; }


public String getBrand() { return brand; }
public int getYear() { return year; }
public double getPrice() { return price; }

public String toString()


{
return "\nSerial Number: " +serialNo+ "\nBrand: " +brand+ "\nYear: " +year+
"\nPrice: RM " +price;
}
}

public class ListNode


{
Object data;
ListNode next;

ListNode(Object o)
{
this(o, null);
}

ListNode(Object o, ListNode nextNode)


{
data = o;
next = nextNode;
}

Object getObject()
{
return data;
}

ListNode getNext()
{
return next;
}
}

public class LIST


{
private LIST firstNode;
private LIST lastNode;
private LIST currNode;

public LIST()
{
firstNode = lastNode = null;
}

public void insertData(Object


{

import javax.swing.*;
import java.util.*;
import java.lang.*;

public class mainComputer{


public static void main(String args[])
{
LinkedList compList = new LinkedList();
String choice = JOptionPane.showMessageDialog("Enter choice \n1-Input
data \n2-Display
\n3-Search \n4-Count \n5-
Delete
\n6-Display current list
\n7Exit");
int nChoice = Integer.parseInt(choice);

while (nChoice != 0)
{
if(nChoice == 1) //enter data
{
String bilData = JOptionPane.showInputDialog("How many data? ");
int bil = Integer.parseInt(bilData);

for(int i=0; i<bil; i++)


{
int CSerial = JOptionPane.showInputDialog("Enter serial number:
");
String CBrand = JOptionPane.showInputDialog("Enter brand: ");
int CYear = JOptionPane.showInputDialog("Enter year: ");
double CPrice = JOptionPane.showInputDialog("Enter price: ");

Computer comp = new Computer(CSerial, CBrand, CYear, CPrice);


}

Anda mungkin juga menyukai