-
single linked list.. so confused...
hi! i need to make a program using a single link list... i have to store information on motorbikes wherein each motorbike contain brand, price, etc... I have no idea how to do this.. I can do this using array but not with link list.. i only know a bit about single link list and i don't have any idea where to start.. should i make a class that contains those info like brand and price? but i am supposed to make a linked list.. i've been trying to study linked list for like ages now and i don't still know how to start with the program.. i cud probably do the adding, and deleting nodes from the linked list.. but how about those information about brand and prices?.. badly need help... i need this 2 days from now... pls...
-
One approach is to use a Node class, which has a "next" data field, which will hold a reference to the node which is "next" in the linked list. Your node can also have the information about motorbikes as a part of the class, or it can hold an instance of a Motorbike class (more OOP like).
There is a lot of code available on the Internet - Google
"java linked list goodrich" and some good stuff will return
-
i am not getting what u said about the node having information about motorbikes..
should the Node class look like this?
class Node{
private String value;
private Node next;
private String plate;
private String brand;
private int price;
private int speed;
}
public Node(String s, node n, String p, String b, int pr, int sp){
value =s;
node =n;
plate=p;
brand=b;
price=pr;
speed=sp;
}
//accessors and mutators here...
is that it? or am i wrong?
-
either set it up as
class Node
{
private Motorbike bike;
private Node next;
public Node( Motorbike bike; Node next )
{
this.bike = bike;
this.next = next;
}
and various methods here
}
or
class Node{
private Node next;
private String plate;
private String brand;
private int price;
private int speed;
etc.
}
Similar Threads
-
By Dark Rain in forum C++
Replies: 11
Last Post: 02-18-2007, 12:06 PM
-
Replies: 1
Last Post: 11-04-2005, 06:19 AM
-
By white94cam in forum C++
Replies: 2
Last Post: 03-30-2005, 11:02 PM
-
Replies: 146
Last Post: 08-12-2002, 10:40 PM
-
By Rob Teixeira in forum .NET
Replies: 129
Last Post: 06-06-2002, 05:23 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks