S.O.S. Mathematics CyberBoard

Your Resource for mathematics help on the web!
It is currently Wed, 19 Jun 2013 10:19:05 UTC

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Need some help in Java...
PostPosted: Thu, 7 Jul 2005 21:28:58 UTC 
Offline
Senior Member

Joined: Mon, 21 Jun 2004 15:56:08 UTC
Posts: 69
I am getting a bunch of errors after compiles this code... Mostly is invalid declarations and return values errors. There is also one inconvertible type

I can't figure out what's wrong...

This is the guideline of the class file

Class Store should have two instance variables name and items, of type String and List respectively. It should provide methods addItem(StoreItem anItem) and removeItem(StoreItem anItem) to add and remove items from the store. Additionally, it should implement methods audioVideoItems() and photoItems() to return an Iterator for the available audio-video, and photo items along with the method authors() to return an iterator for all authors whose work is available through the store.

Here is my code

Code:
import java.util.*;

public class Store
{
   private String[] name;
   private List items = new Vector();
   
   public addItem(StoreItem anItem)
   {
      items.add(anItem);
   }
   
   public removeItem(StoreItem anItem)
   {
      items.remove(anItem);
   }
   
   public audioVideoItems()
   {
      Iterator name = items.iterator();
      while(name.hasNext())
      {
         String aString = (String)name.next();
         return name;
      }
   }
   
   public photoItems()
   {
      Iterator name = items.iterator();
      while(name.hasNext())
      {
         String aString = (String)name.next();
         return name;
      }
   }
   
   public authors()
   {
      Iterator name = items.iterator();
      while(name.hasNext())
      {
         String aString = (String)name.next();
         return name;
      }
   }
   
   public String getName()
   {
      return (String)name;
   }
   
   public List getItems()
   {
      return items;
   }
   
   Store(String[] aName, List anItem)
   {
      name = aName;
      items = anItem;
   }
   
   public String toString()
   {
      return ("");
   }
}


Last edited by simple on Wed, 9 Feb 2011 05:14:54 UTC, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu, 7 Jul 2005 22:10:00 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame
User avatar

Joined: Sun, 4 May 2003 16:04:19 UTC
Posts: 2906
it would help if you tell us *exactly* what those errors are.

_________________
Has anyone noticed that the below is WRONG? Otherwise this statement would be true:
-1\cong1\pmod{13}
i\cong5 \pmod{13} where
i^2=-1


Top
 Profile  
 
 Post subject:
PostPosted: Thu, 7 Jul 2005 22:29:19 UTC 
Most of your methods don't have return types. if they return nothing, make sure to state that with 'void' so for example:

public void addItem ( ... )

Also, you're returning a value while in a while loop, that's ridiculous if you're not returning a recursive call to some method. It will only execute once. Your constructor should be public, too.

-- X Conrad X


Top
  
 
 Post subject:
PostPosted: Fri, 8 Jul 2005 18:45:45 UTC 
...you're welcome, by the way.

-- X Conrad X


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Contact Us | S.O.S. Mathematics Homepage
Privacy Statement | Search the "old" CyberBoard

users online during the last hour
Powered by phpBB © 2001, 2005-2011 phpBB Group.
Copyright © 1999-2013 MathMedics, LLC. All rights reserved.
Math Medics, LLC. - P.O. Box 12395 - El Paso TX 79913 - USA