Ok you guys are my last hope, i've tried searching what i need and i cant find it. i really tried searching.... but i just don't know exactly what i'm really searching for...
i have to do the following project in c# (wrong post haha) but if you could help out in java i could just "translate" it to c# really doesn't matter http://personal.cityu.edu.hk/~dcrosela/teaching/04-05/dco20105/lab/figures/lab1/soln-one-uml-gou-cof.jpg so if anyone could help i'm stuck on the order part where it has to get a product i have a catalogProdcts<Products> that hold products so im not sure if i have to point my order to catalogproduct and use my method get product to retrieve a certian product heres some code...
public class Catalog
{
private Generica<Product> lista;
public Catalog() {
lista = new Generica<Product>();
}
public void agregar(Product prod) {
lista.add(prod);
}
public Product getProducto(int index) {
return lista.get(index);
}
public Product getProducto(String codigo){
foreach (Product p in lista ){
if (p._code.Equals(codigo)){
return p;
}
}
return null;
}
public bool borrar(int index) {
return lista.eliminar(index);
}
public void modificar(int index, Product prod) {
lista.modifica(index, prod);
}
public int length() {
return lista.Count;
}
}
public class Product
{
private String code;
private String description;
private double price;
public Product(String code, String description, double price)
{
this.code = code;
this.description = description;
this.price = price;
}
public String _code
{
get { return code; }
}
public String _description
{
get { return description; }
}
public double _price
{
get { return price; }
}
public int CompareTo(object obj)
{
if (obj is Product)
{
Product prod = (Product)obj;
if (this.price < prod.price)
{
return -1;
}
else
{
if (this.price > prod.price)
{
return 1;
}
else
{
return 0;
}
}
}
else
{
throw new System.InvalidCastException("Tipos no comparables");
}
}
public int CompareTo(Product other)
{
if (other is Product)
{
Product prod = (Product)other;
if (this.price < prod.price)
{
return -1;
}
else
{
if (this.price > prod.price)
{
return 1;
}
else
{
return 0;
}
}
}
else
{
throw new System.InvalidCastException("Tipos no comparables");
}
}
}
and what i have for orderItem
class OrderItem //: IComparable<OrderItem>
{
int _quantity;
private Product _product;
public OrderItem(int quantity)
{
this._quantity = quantity;
}
public int quantity
{
get { return quantity; }
set { _quantity = value; }
}
public Catalog getProducto(String codigo)
{
Catalog
return c;
}
}
Help please!!!! (: