Monday, February 9, 2009

/*Programmer:Miexie D. Tulid
*Title:ClothingTester class
*Status: it really work.! Try mo....*/


import javax.swing.JOptionPane;

public class ClothingTester
{
public static void main(String ars[]){
Shirt shirt1=new Shirt(0,20,"dark","men's wear",2);
Shirt shirt2=new Shirt(1,6,"red","ladies' wear",7);
Shirt shirt3=new Shirt(2,17,"rainbow","children's wear",5);


System.out.println(shirt1.displayInformation()+"\n\n");
System.out.println(shirt2.displayInformation()+"\n\n");
System.out.println(shirt3.displayInformation()+"\n\n");




String ans="mix";

while(ans!="Yes"||ans!="No"){
ans=JOptionPane.showInputDialog("Would you like to place an order?\n(Yes/No)");
if(ans.equals("Yes")){
JOptionPane.showMessageDialog(null,"Please fill in the following form.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);
String id=JOptionPane.showInputDialog("Enter your id");
String name=JOptionPane.showInputDialog("Enter your name");
String address=JOptionPane.showInputDialog("Enter your address");
String phone=JOptionPane.showInputDialog("Enter your phone number");
String email=JOptionPane.showInputDialog("Enter your e-mail address");
JOptionPane.showMessageDialog(null,"Thank you!\nNow please fill in the order form.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);
String shirtord=JOptionPane.showInputDialog("Enter the shirt id you want to purchase");
String quanord=JOptionPane.showInputDialog("Enter the quantity");
int cid=Integer.parseInt(id);
int shirtno=Integer.parseInt(shirtord);
int shirtquan=Integer.parseInt(quanord);
Customer customer=new Customer(cid,name,address,phone,email,shirtno,shirtquan);
System.out.println(customer.placeorder());
JOptionPane.showMessageDialog(null,"Look at your profile on the screen!","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Thank you!\nNow fill in the payment form","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);
String fpayment="mix";
while(fpayment!="Credit card"||fpayment!="Check"){
fpayment=JOptionPane.showInputDialog("Enter your form of payment\n(Credit card/Check)");
if(fpayment.equals("Credit card")){
String screditno=JOptionPane.showInputDialog("Enter your credit card no");
String date=JOptionPane.showInputDialog("Enter its expiration date");
int creditno=Integer.parseInt(screditno);
FormofPayment payment=new FormofPayment(fpayment,creditno,date);
JOptionPane.showMessageDialog(null,"Submit?","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

String submit="mix";
while(submit!="Ok"){
String svcreditno=JOptionPane.showInputDialog("Verify your credit card no");
int vcreditno=Integer.parseInt(svcreditno);
submit=payment.verifyCardno(vcreditno);
if(submit.equals("Ok")){
JOptionPane.showMessageDialog(null,"Your credit card has been verified!","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}
else{
JOptionPane.showMessageDialog(null,"Your credit card has been denied!\nPlease try again.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}
}//end submit while

}//end if credit
else if(fpayment.equals("Check")){
String screditno=JOptionPane.showInputDialog("Enter your check no");
String date=JOptionPane.showInputDialog("Enter its expiration date");
int creditno=Integer.parseInt(screditno);
FormofPayment payment=new FormofPayment(creditno,date);
JOptionPane.showMessageDialog(null,"Submit?","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

String submit="mix";
while(submit!="Ok"){
String svcreditno=JOptionPane.showInputDialog("Verify your check no");
int vcreditno=Integer.parseInt(svcreditno);
submit=payment.verifyChekPayment(vcreditno);
if(submit=="Ok"){
JOptionPane.showMessageDialog(null,"Your check has been verified!","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}
else{
JOptionPane.showMessageDialog(null,"Your check has been denied!\nPlease try again.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}
}//end submit while

}//end elseif credit

else{
JOptionPane.showMessageDialog(null,"Invalid input!\nPlease try again.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}




}

}
else if(ans.equals("No")){
JOptionPane.showMessageDialog(null,"Goodbye!","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}

else {
JOptionPane.showMessageDialog(null,"Invalid input!\nPlease try again.","Clothing Order Interface",JOptionPane.PLAIN_MESSAGE);

}





}
}
}
/*Programmer:Miexie D. Tulid
*Title:Shirt class*/


public class Shirt
{
public int shirtID;
private double price;
private String color;
private String description;
private int quantity;

public Shirt(int newshirtID, double newprice, String newcolor, String newdescription, int newquantity)
{
shirtID=newshirtID;
price=newprice;
color=newcolor;
description=newdescription;
quantity=newquantity;
}


public int addStock( int stock)
{
quantity=quantity+stock;
return quantity;
}


public int removeStock( int stock)
{
quantity=quantity-stock;
return quantity;
}


public String displayInformation()
{
return String.format("ShirtID:"+shirtID+"nPrice:"+price+"\nColor:"+color+"\nDescription:"+description+"\nQuantity:"+quantity);

}
}
/*Programmer:Miexie D. Tulid
*Title:Catalog class*/


public class Catalog
{
int x=0;
Shirt shirtobjects[]=new Shirt[3];

public Catalog(int id,double p,String c, String d, int q){
shirtobjects[id]=new Shirt(id,p,c,d,q);
}



public void addShirt(int id,double p,String c, String d, int q){

for(int y=0;y
if(shirtobjects[y].shirtID==id)
{q=shirtobjects[y].addStock(q);
shirtobjects[y]=new Shirt(id,p,c,d,q);
}
else{
shirtobjects[id]=new Shirt(id,p,c,d,q);

}}

}

public void removeShirt(int id,double p,String c, String d, int q){

for(int y=0;y if(shirtobjects[y].shirtID==id)
{q=shirtobjects[y].removeStock(q);
if(q==0){

shirtobjects[y]=new Shirt(0,0,"none","none",0);
}
else{
shirtobjects[y]=new Shirt(id,p,c,d,q);

}
}

}
}
public String generateString(int z){
return String.format(shirtobjects[z].displayInformation());
}


}
/*Programmer:Miexie D. Tulid
*Title:Form of Payment class*/


public class FormofPayment
{

private int checkno;
private int cardno;
private String expiredate;
private String fpay;

public FormofPayment(String fpayment,int creditno,String xdate)
{
fpay=fpayment;
cardno=creditno;
expiredate= xdate;
}
public FormofPayment(int chek,String xdate)
{
checkno=chek;
expiredate= xdate;
}


public String verifyCardno(int newcardno)
{
if(cardno==newcardno){
return String.format("Ok");}

else{

return String.format("Not");}
}

public String verifyChekPayment(int newcheckno)
{
if(checkno==newcheckno){

return String.format("Ok");}

else{

return String.format("Not");}
}
}
/*Programmer:Miexie D. Tulid
*Title:Form of Payment class*/


public class FormofPayment
{

private int checkno;
private int cardno;
private String expiredate;
private String fpay;

public FormofPayment(String fpayment,int creditno,String xdate)
{
fpay=fpayment;
cardno=creditno;
expiredate= xdate;
}
public FormofPayment(int chek,String xdate)
{
checkno=chek;
expiredate= xdate;
}


public String verifyCardno(int newcardno)
{
if(cardno==newcardno){
return String.format("Ok");}

else{

return String.format("Not");}
}

public String verifyChekPayment(int newcheckno)
{
if(checkno==newcheckno){

return String.format("Ok");}

else{

return String.format("Not");}
}
}
/*Programmer:Miexie D. Tulid
*Title:Customer class*/


public class Customer{
private int cid;
private String cname;
private String caddress;
private String cphone;
private String cemail;
private int cshirtno;
private int cshirtquan;

public Customer(int id,String name,String address,String phone,String email,int shirtno,int shirtquan){
cid=id;
cname=name;
caddress=address;
cphone=phone;
cemail=email;
cshirtno=shirtno;
cshirtquan=shirtquan;

}

public String placeorder(){
return String.format("CustomerID:"+cid+"\nCustomer name"+cname+"\nAddress:"+caddress+"\nPhone number:"+cphone+
"\nEmail address:"+cemail+"\nShirt Id:"+cshirtno+"\nQuantity:"+cshirtquan);

}
}
/*Programmer:Miexie D. Tulid
*Title:Order class
*Status:unfinished*/


public class Order{

private int orderid;
private double totalprice;
private String status;
}
//Program Name: CubeTester.java
//Programmer: Miexie D. Tulid
//Description: A class program that already tests the class Cube.java
//Date: February 04, 2009


import javax.swing.JOptionPane;
public class CubeTester{
public static void main(String args[]){
Cube Cube1=new Cube(2,2,2);
Cube Cube2=new Cube();




JOptionPane.showMessageDialog(null,"The volume and area of constructor having a parameter is: "+Cube1.displayCube(),"Volume and Area of a Cube",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Now lets go to the constructor without a parameter!");
String w=JOptionPane.showInputDialog("Enter your width: ");
String h=JOptionPane.showInputDialog("Enter your height: ");
String l=JOptionPane.showInputDialog("Enter your lenght: ");

double a=Integer.parseInt(w);
double b=Integer.parseInt(h);
double c=Integer.parseInt(l);

Cube2.setDimension(a,b,c);
JOptionPane.showMessageDialog(null,"The volume and area of constructor having no a parameter is: "+Cube2.displayCube(),"Volume and Area of a Cube",JOptionPane.PLAIN_MESSAGE);

}
}
//Program Name: Cube.java
//Programmer: Miexie D. Tulid
//Description: A class program that allows to manipulate the area and volume of a cube using a constructor with and without a parameter.
//Date: February 04, 2009


public class Cube{

private double cwidth;
private double clength;
private double cheight;





public Cube(double width, double height, double length)
{
this.cwidth=width;
this.cheight=height;
this.clength=length;
}

public Cube()
{

}

private double volume()
{

return (cwidth*clength*cheight);

}


private double area()
{

return (cwidth*clength);

}


public void setDimension(double newwidth, double newheight, double newlength)
{
this.cwidth=newwidth;
this.cheight=newheight;
this.clength=newlength;
}

public String displayCube()
{
return String.format(volume()+" and "+area());

}
}