Peter Kay

Greenhorn
+ Follow
since Nov 24, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Peter Kay

Thanks a lot it all works now
I have never tried using casting with my own objects, ive only ever used it with numbers so it never crossed my mind to even try it.
Thanks again, really helped
20 years ago
Well to be honest its part of a project. I have a linked list (bunch of objects, one set as the start with each one pointing to the next one).
The code for the linked list as well as the objects is already done and probably shouldn't be changed.
The objects in this are the OBjectStoreTwo in that they contain another object from a different class. Im trying to store the PaintCan inside the objects and use a different class (Shelf) to add/remove and look on the shelf.
In the shelf class i have a method:
public void AddPaintCan(String brand, String color, int size)
{ paintCan = new PaintCan(brand, color, size); }
The linked list is declared as LL
With another method which uses this method:
[input for brand, color and size. All working and tested as well as the AddToLinkedList method]
LL.AddToLinkedList(Beginning, paintCan);
I can then use a System.out.print(LL.Look(1)); to show the pointer to the paintcan or:
System.out.print(paintCan.brand); to show the brand from the last entered paintcan.
The problem is when i try to use something like:
Object thisPaintcan = LL.Look(1);
System.out.print(thisPaintcan.brand);
I am sorry if this is confusing (its confusing for me as well ).
20 years ago
Im still stuck with this so i will try explaining the problem again. I think this time it might be with the way i am storing variables inside objects which might be causing the problems.
I have a class called ObjectStore which has 2 strings and an int in it.
ObjectStore(String one, String two, int three) {this.one = one; ...
I then have another class called ObjectStoreTwo which stores an object in it
I then have a third class which uses some methods to collect the string + ints and store them in objectStore and then it stores ObjectStore in the object field of ObjectStoreTwo.
Now i am trying to call the data back using another class. At the moment i can use ObjectStore.one to get the last set of data to be used there but ObjectStoreTwo.ObjectStore.one says cannot resolve symbol.
I have a method Look(number) which gets the ObjectStoreTwo with the number assigned to it, but it doesnt work if i try to use either:
System.out.println (Look(1).ObjectStore.one);
or
Object ThisObject = Look(1);
System.out.println (ThisObject.ObjectStore.one);
Any ideas?
20 years ago
I am having difficulties getting strings to output when they are in an object which is inside another object. Best i have done so far is display the pointer for the 2nd object which is not very useful.
Ill ignore the first object for the moment because i am able to access the 2nd object. Ill call the 2nd object "secondObject" and one of the strings "stringIWant"
If i use System.out.println(secondObject) then it displays the pointer so i tried using System.out.println(secondObject.stringIWant) but this gives the errors:
cannot resolve symbol
symbol : variable stringIWant
location : class.java.lang.Object

There any ideas on how i can get the string to output?
Thanks,
Peter Kay.
20 years ago