Friday, February 10, 2006

FINALLY DONE WITH OOP! :/ pheww. BIG BIG thanks to ROBIN! (: for helping me! and also thanks to ALVIN! (: alicia is done with hers too! yay! haha. finallyy. got kinda stressed about it yesterday that i nearly went mad. :/

have a loook at our work. :/

public static void addItem(Customer name){
Stationary item;
String add = JOptionPane.showInputDialog(null,
"To purchase:\nPaper: Key in'1', colour, weight of paper required (in grams)\n"
+"Ribbon: Key in '2', colour, length of ribbon required (in cm)",
"Purchase Stationary",
JOptionPane.PLAIN_MESSAGE);

StringTokenizer st = new StringTokenizer(add,",");
int num = Integer.parseInt( st.nextToken() );
String colour = st.nextToken();
double amount = Double.parseDouble( st.nextToken() );

if (num == 1)
item = (Stationary) new Paper(colour,amount);
else
item = (Stationary) new Ribbon(colour,amount);

name.addOrder(item);
}


this one is done by robin. show you one done by some year 3 senior.

public void addToCart() {
String type;
String colour;
double prop;
try {
String a = JOptionPane.showInputDialog(this, "To purchase:\nPaper: key in \"1\",color,weight of paper required (in grams)\nRibbon: key in \"2\",color, length of ribbon required (in cm)", "Purchase Stationary", JOptionPane.QUESTION_MESSAGE);
if (a != null) {
st = new StringTokenizer(a, ",");
type = st.nextToken().trim();
colour = st.nextToken().trim();
prop = Double.parseDouble(st.nextToken().trim());

Stationary b = null;
if (type.equals("1")) {
b = new Paper(colour, prop);
}
else if (type.equals("2")) {
b = new Ribbon(colour, prop);
}
else {
throw new Exception();
}
stationaries.add(b);
}

} catch (Exception ex) {

JOptionPane.showMessageDialog(this, "Please key in according to the format given");
addToCart();
}

}


see until headache. :/ OOP is driving me and my girl NUTS. but hopefull we'll pass. exam at 5:30pm - 7:00pm. GOOD LUCK to us.

and THANK YOU to daddy. for buying my 1GB compact flash card from me. i sold it to him at $90! hahaa. love you daddy.

bettina | 3:57 PM


 

stylegoddess;
-----------------------------------------

I'm 19. I'm a chinese Singaporean. I'm attached and lovin' it. I'm studying in Ngee Ann Poly. I love singing. I'm a movie bum. I'm a cam-whore. I'm easily contented. I'm in love with Chuan Kai and forever will be. I'm Bettina.

upcoming events;
-----------------------------------------

03 NOV -- Baby back from field camp!
03 NOV -- Alex's bdae
10 NOV -- Baby's BIRTHDAY!
11 NOV -- Charmaine's bdae
12 NOV -- 11th Month Anni!
14 NOV -- Azzah's bdae
20 NOV -- Elysia's bdae
23 NOV -- Agnes's bdae

navigate;
-----------------------------------------





tagboard;
-----------------------------------------

wishlist;
-----------------------------------------



the past;
-----------------------------------------

September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
August 2007