Hi everybody,
this is literally the first time i have ever posted anything on a forum, i am hoping i enjoy it and looking forward to using regularly.
if i provide the code then explain the nature of my problem
class 1:
import java.util.*; public class Item implements Comparable { private String id; private String name; private double retail; private int quantity; private double price; Item(String idIn, String nameIn, String retailIn, String quanIn) { id = idIn; name = nameIn; retail = Double.parseDouble(retailIn); quantity = Integer.parseInt(quanIn); if (quantity > 400) price = retail * .5D; else if (quantity > 200) price = retail * .6D; else price = retail * .7D; price = Math.floor( price * 100 + .5 ) / 100; } public int compareTo(Object obj) { Item temp = (Item)obj; if (this.price < temp.price) return 1; else if (this.price > temp.price) return -1; return 0; } public String getId() { return id; } public String getName() { return name; } public double getRetail() { return retail; } public int getQuantity() { return quantity; } public double getPrice() { return price; } }
class 2:
the first class compiles fine. the second class will not compile. i originally tried to put them in packages but gave up on that. now i just want the second class file to compileimport java.util.*; public class Storefront { private LinkedList catalog = new LinkedList(); public void addItem(String id, String name, String price, String quant) { Item it = new Item(id, name, price, quant); catalog.add(it); } public Item getItem(int i) { return (Item)catalog.get(i); } public int getSize() { return catalog.size(); } public void sort() { Collections.sort(catalog); } }
can anyone help
will be much appreciated :-)