Solved

Passing objects to linked list!

Posted on 2004-04-11
6
205 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
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 130 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
backtracking recursion  code 19 58
java 8 lambda expresssions exception handling 3 89
eclipse java  build path 6 56
netstat -ano | find "8000" and taskkill /f /pid 2984 3 56
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

770 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