?
Solved

Passing objects to linked list!

Posted on 2004-04-11
6
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
This video teaches viewers about errors in exception handling.
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 Month8 days, 22 hours left to enroll

764 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