Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

sportsItem class

Thread view: 
steedownes - 08 Nov 2005 02:21 GMT
I am trying to construct a SportsItem class( with the variables below)
keep getting illegal errors. Where am i going wrong?

public class sportsItem
{

       private String Description;
       private String Price;
       private int Quantity;
       private int quantityReorder;
       private String Supplier;

       /**
        * Constructor for objects of class item
        */
here' the error    public sportsItem(String Description, String Price,
int Quantity, int quantityReorder, String Supplier)
       )

       {

           this.sportsitem= sportsItem;
           this.description= description;
           this.quantity= quantity;
           this.quantityReorder= reorderQuantity;

       }

       public String getItem;
       {
           return item;
          }

       public String getDescription;
       {
           return description;
          }

   public int getQuantity()
       {
           return quantity;
          }

       public int getquantityReorder()
       {
           return quantityReorder;
          }
E11 - 08 Nov 2005 03:15 GMT
The first line in your constructor:

>             this.sportsitem= sportsItem;

What are you trying to do here?

Regards,
Edwin
steedownes - 08 Nov 2005 05:44 GMT
Im trying to a class SportsItem and then supplier as an object of that
class. The SportsItem has the below variables. I want to be able to
reduce  the stock quantity accordingly when items are sold. The sale of
1 or more items.

Also i need a method to show when stock has fallen below its reorder
quantity so it can be restocked and be incresed accordingly

here's what i have so far

public class sportsItem {

       private String  description;
       private String  price;
       private int     quantity;
       private int     quantityReorder;
       private String  supplier;
       private String  sportsitem;

       /**
        * Constructor for objects of class item
        */

       public sportsItem(String sportsItem, String description, String
price,
                       int quantity, int quantityReorder, String
supplier) {

               this.sportsitem                 = sportsItem;
               this.description                = description;
               this.price                      = price;
               this.quantity                   = quantity;
               this.quantityReorder            = quantityReorder;
               this.supplier                   = supplier;
       }

       public String getSportsItem()   {
               return this.sportsitem;
       }
       public String getDescription()  {
               return this.description;
       }
       public String getPrice()        {
               return this.price;
       }
       public int getQuantity() {
               return this.quantity;
       }
       public int getQuantityReorder() {
               return this.quantityReorder;
       }
       public String getSupplier() {
               return this.supplier;
       }

}
----------------------------------------------------------------------------------------------------------

public class Supplier {

        /**
        * Constructor for objects of class Supplier
        */

   private String name;
   private String phonenumber;
   private String emailaddress;
   private String sportsitem;

        /**
        * Constructor for objects of class Supplier
        */

    public Supplier (String name, String phonenumber, String
emailaddress){

        this.name                 = name;
        this.phonenumber          = phonenumber;
        this.emailaddress         = emailaddress;
        this.sportsitem           = sportsitem;

    }

     public String getname;           {
             return this.name;
    }
     public String getphonenumber;   {
            return phoneNumber;
    }
     public String getemailAddress;   {
            return emailaddress;
    }
     public int reduceQuantity()      {
            stock = Quantity - sportsItem;
    }
     public int reorderquantity()     {
            return stockquantity;
    }
     public String getquantityreorder(){
            return stockquantity() - SportsItem();     }

         public void print()
    {
        System.out.println(name + " (" + phoneNumber + ")");
        System.out.println("Suppliers name is:  " +
SportsItem.getName());
        System.out.println("Suppliers emailAddress is:  " +
SportsItem.getemailAddress());
    }
}

regards,
Iyara
Roedy Green - 08 Nov 2005 06:05 GMT
>Also i need a method to show when stock has fallen below its reorder
>quantity so it can be restocked and be incresed accordingly

Break that into two problems:

write a method to determine if a stock is below reorder.

cycle through all the stock calling that method and calling the
matching reorder method.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Bjorn Abelli - 08 Nov 2005 11:53 GMT
"Roedy Green" wrote...

>> Also i need a method to show when stock has fallen below
>> its reorder quantity so it can be restocked and be
[quoted text clipped - 3 lines]
>
> write a method to determine if a stock is below reorder.

That one goes into the SportsItem class...

> cycle through all the stock calling that method and
> calling the matching reorder method.

...but that one goes into the class that aggregates SportsItems...

Just to clarify things for the OP...

// Bjorn A
Bjorn Abelli - 08 Nov 2005 11:47 GMT
"E11" wrote...

> The first line in your constructor:
>
>>      this.sportsitem = sportsItem;
>
> What are you trying to do here?

The OP is assigning the value of the argument sportsItem to the instance
variable sportsitem.

It's much of a common practice in many places to use the same names (or at
least similar) for both arguments and the variables they "represent".

Nothing strange about that.

// Bjorn A
Bjorn Abelli - 08 Nov 2005 11:52 GMT
"Bjorn Abelli" wrote...
> "E11" wrote...
>
[quoted text clipped - 6 lines]
> The OP is assigning the value of the argument sportsItem
> to the instance variable sportsitem.

Aaah, now I looked more closely to it, I noticed there *wasn't* neither an
argument or an instance variable with that name.

Now, that's a cause of error, just as E11 said...

// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.