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
Solved

Passing objects to linked list!

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure a Bean in an XML file 4 42
Android development question 2 52
jmss example java 2 23
Java syntax, or is it Selenium 6 30
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

809 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