I coded till I wore out, study OO. Set down on the project and figure stuff like Customer has Bill and just do whatever OO tells you to do.
|
Code:
|
// A customer.
class Customer
{
int id;
boolean done;
private List<Bill> lb;
Customer(){lb = new List<Bill>();}
Customer(int id){this();id = id}
void checkOut(){done = true;}
Address getAddress(){}
List<Bill> getBills() {return }
+findBillById(int id) Bill
+findBillByDate(Date date) Bill
+findCurrentBill() Bill
+getCart() ShoppingCart
}
// Class Bill
class Bill
{
//
final BigDecimal TAX_RATE;
static{TAX_RATE = new BigDecimal(123456.7890);}
Date date;
Integer id;
Address address;
Date <create>
ArrayList<Item> Items;
double subTotal;
double totalTax;
double totalCost;
Bill (List<Item> items)
{
// This will need a cast or some further work.....
Items = items;
Bill(int id, List<Item> items)
{
id = new Integer(id);
Items = items;//
}
Address getAddress(){return address;}
void setAddress(String[] data){Address = new (data);}
Date getDate(){return date;}
void setDate{ date = new Date(); }
ArrayList<Item> getItems(){return Items;}
}
}
class Address
{
String street_number;
String street_name;
String citadel_name;
String estacion_de_residence;
String country_of_residence;
// preliminary constructor .....
Address(String[] data)
{
street_number = data[0];//
street_name = data[1];//
citadel_name = data[2];//
estacion_de_residence = data[3];//
country_of_residence = data[4];//
}
}
class Item
{
String name;
String description;
String vendor;
Item(String name, String description, String vendor)
{
name = name;
description = description;
vendor = vendor;
}
} |
That's got to be the most unusual editor I have ever seen, can you post in our what editor are you using Thread and explain where + became Java code?