• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Having problems with an arrays assignment

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heres my testing program:



Heres my list class, which is the one I'm having problems coding...I'm not sure how to set this one up.



other classes include:


and the base class is:



Any help would be appreciated!!
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok in the MallList class you have too many ';', and MallList doesn't
have a constructor with three arrays as parameters..

you have the following code, but no constructor for it.

MallList list = new MallList(String[],double[],int[]);

now MallItem does, but they are not arrays.

you need to pass a String[] name, double[] price, int[] store.

so in other words, change MallItem's argument constructor to

public MallItem(String[] name, double[] price, int[] store)
{
// etc.
}

and then instead of instantiating a object of type MallList, make one
of type MallItem.

Justin Fox
[ March 01, 2007: Message edited by: Justin Fox ]
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and for you problem with the MallList class, you need to pass
a MallItem as a parameter to the constructor of MallList.

like:



now, for the MallList class, it's purpose is not really
all that neccesary..

unless MallList just has a collection or arraylist of
MallItems.

but anyways, hope that helps a little

Justin Fox
 
Shananne DuFrame
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok... I tried to make changes of what I understood. I also added a few more thngs that I will need. Right now I am just trying to accomplish getting the list to print and the program to work. I will be adding methods after to print in reverse, addItems, removeItems and such. Right now I am just concerned with getting a working program that prints what is in the list.

Right now all classes compile... but my output is like this:

----jGRASP exec: java TestListStudent

Is the list full? false
MallList@45a877

----jGRASP: operation complete.

At least its compiling, its farther than I was before.
Heres my code again


Test Class


Base class Item:


Derived class:


MallList Class:
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MallItem itemOne = new MallItem("jeans",40.00,16);

that is the format for MallItem

what you need to do is like the following




Justin
 
Shananne DuFrame
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it working...Thanks for your help.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no problem, sorry for "beating around the bush" but I wanted to help you learn how to identify the exact problem and find a solution for that problem, one problem at a time.


Justin
 
Shananne DuFrame
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a problem....learn more that way. Sometimes from trial and error also. I had to try a few things a few times but I got it. Thanks!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic