?
Solved

Passing objects to linked list!

Posted on 2004-04-11
6
Medium Priority
?
221 Views
Last Modified: 2010-03-31
Greetings everyone!

Background:

I got this uni project for printerjobs where i'm using singly linked list. the approch i'm taking is instead of declaring the varibles(Printer name, printer source, doc name etc..) in the node class i created another class called printer jobs and i only created a varible of object type. in printer jobs i have all the setters and getterin there instead of the node class.

when adding i add the printerjob object which have values of (Printer name, printer source, doc name etc..) to data object in node class and so on....

PrinterJob myPrinterJob = new PrinterJob("New Printer Job");
myPrinterJob.setJobNo(1);
myPrinterJob.setJobPrio(1);
myPrinterJob.setJobSource("CPA1");
myPrinterJob.setDocName("EasyProgramming.doc");
myPrinterJob.setDocSize("3 MB");
Passing object to link list but....


myPrinterQueue.addToTail(myPrinterJob);

PrinterJob myPrinterJob2= new PrinterJob("New Printer Job");
myPrinterJob.setJobNo(1);

and so on................

Problem:

Now i'm implenting my program in dos prombt, so i want to add unlimited number of data with having to create new printerjob object everytime when i'm adding i want it to create itself everytime heres the link of my app

http://www.qandala.com/1.zip


looking forward for help

Abdi
0
Comment
Question by:qandala
  • 2
4 Comments
 
LVL 5

Expert Comment

by:lwinkenb
ID: 10801703
What do you mean by wanting it to create itself?
0
 

Author Comment

by:qandala
ID: 10802120
I mean instead of creating fixed number of objects data type inside the file i want to be able to store/pass objects in the node!

Object myObject= new Object();
List.addToTail(myObject)

but what i want is a way where i can make/create objects new object everytime when adding!

i hope you understode what i meant

Regards
0
 

Author Comment

by:qandala
ID: 10805599
I mean instead of creating fixed number of objects data type inside the file i want to be able to store/pass objects in the node!

Object myObject= new Object();
List.addToTail(myObject)

but what i want is a way where i can make/create objects new object everytime when adding!

i hope you understode what i meant

Regards
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 520 total points
ID: 10806041
>>but what i want is a way where i can make/create objects new object everytime when adding

If you wanted an 'auto-initialise' facility how would it know which values to initialize to? All you could do is provide default values and get the job number from the list size:

//overridden (no arg)

public Node addToTail() {

     PrinterJob myPrinterJob = new PrinterJob("New Printer Job");
     myPrinterJob.setJobNo(getSize());
     //etc
     Node node = new Node(myPrinterJob);
     // set pointers etc.
     return node;

}
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question