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