Monday, February 9, 2009

Program Solution of Direct Clothing Case Study by Lacno, Maribelle

/* Programmer:     Maribelle Lacno
  * Program name: Direct Clothing Case study
  * Subject:     IT134_Computer Programming 3
  * Instructor:     Mr. Dony Dongiapon
  * Date Started: 02/09/09
  * Date Finished: 02/09/09
  * Purpose:     To create an online direct clothing case study.
*/

catalog

public class catalog{

 private String clothes;
 
 private void addShirt(){
  System.out.println("\nShirt jacket is in catalog");
 }

 private void removeShirt(){
  System.out.println("\nShirt jacket is not in catalog");
 }

 public catalog(String newShirt){
  clothes = newShirt;
  this.addShirt();
 }
 public catalog(){
  this.removeShirt();
 }

}

shirt

public class shirt{

 private int shirtID;
 private double price;
 private String color;
 private String description;
 private int quantity;

 private void addStock(){
  customer me = new customer(20060413,"Maribelle","Calapagan",629355,"tulipslady@gmail.com");
 }

 private void removeStock(){
  catalog clothes = new catalog();
  System.out.println("\nJacket has been removed!");
  customer me = new customer();  
 }

 public void displayShirtInfo(){
  catalog clothes = new catalog("jacket");
  System.out.print("\nShirt Information: \nShirtID = "+shirtID+"\nPrice: "+price);
  System.out.print("\nColor: "+color+"\nDescription: "+description+"\nQuantity: "+quantity);
 }

 public shirt(int newID, double newPrice, String newColor, String newDescription, int newQuantity){
  shirtID = newID;
  price = newPrice;
  color = newColor;
  description = newDescription;
  quantity = newQuantity;
  
  this.addStock();
 }
 
 public shirt(){
  this.removeStock();
 }

}

customer

public class customer{

 private int customerID;
 private String name;
 private String address;
 private int phoneNumber;
 private String emailAddress;

 private void placeOrder(){
  System.out.print("\nCustomer "+name+" with an id of "+customerID+"\nwho lived in "+address+", and has a phone number "+phoneNumber);
  System.out.print("\nand email address of "+emailAddress+" wants to make an order.");
  order myOrder = new order(01,600.00,"available");
 }

 private void cancelOrder(){
  System.out.print("\nOrder has been cancelled!");
  order myOrder = new order();
 }

 public customer(int cusID, String cusName, String cusAddress, int cusPhoneNumber, String cusEmailAddress){
  customerID = cusID;
  name = cusName;
  address = cusAddress;
  phoneNumber = cusPhoneNumber;
  emailAddress = cusEmailAddress;
  this.placeOrder();
 }
  public customer(){
  this.cancelOrder();
  }

}

order

import java.util.Scanner;

public class order{
 Scanner scan = new Scanner(System.in);
 private int orderID;
 private double totalPrice;
 private String status;

 private void addShirtToOrder(){
  System.out.print("\nYour shirt has been added to order!");
 }

 private void removeShirtFromOrder(){
  System.out.print("\nYour shirt has been removed from order!");
 }

 public void submitOrder(){
  System.out.print("\nWhat form of payment you have? choose 1(check) or 0(credit card): ");
  int choice = scan.nextInt();
  if(choice==1){
  formOfPayment balance = new formOfPayment();
  }else{
  formOfPayment balance = new formOfPayment(7895,"Feb.14,2009");
  }
  this.addShirtToOrder();
 }

 public void putOrderOnHold(){
  this.removeShirtFromOrder();
 }

 public order(int newOrderID, double totalAmount, String availability){
  orderID = newOrderID;
  totalPrice = totalAmount;
  status = availability;
  this.submitOrder();
 }
 public order(){
  this.putOrderOnHold();
 }

}

formOfPayment

import java.util.Scanner;

public class formOfPayment{
 Scanner scan = new Scanner(System.in);
 private int checkNumber;
 private int creditCardNumber;
 private String expirationDate;

 private void verifyCreditCardNumber(){
  System.out.print("\nCredit Card number accepted!");
 }

 private void verifyCheckPayment(){
  System.out.print("\nCheck number accepted!");
 }

 public formOfPayment(int newCreditCardNumber, String dateExpiration){
  creditCardNumber = newCreditCardNumber;
  expirationDate = dateExpiration;
  
  this.verifyCreditCardNumber();
 }
 public formOfPayment(){
  this.verifyCheckPayment();
 }
}

directClothingTester

import java.util.Scanner;

public class directClothingTester{
 public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
  System.out.print("\n*Welcome to Online Direct Clothing*\nAn official website in which you can order different clothes.");
  System.out.print("\nDo you want to make an order? choose 1(yes) or 0(no): ");
  int choice = scan.nextInt();
  if(choice==1){
  shirt jacket = new shirt(9863,300.00,"green","small",8);
  jacket.displayShirtInfo();
  }else{
  System.out.print("\nDo you want to removed an existing order? choose 1(yes) or 0(no): ");
  int answer = scan.nextInt();
  if(answer==1){
  shirt jacket = new shirt();
  }else{
  System.out.println("\nThanks for ordering!");
  }
 }
}
}

Wednesday, February 4, 2009

cube solution

/* Programmer:       Maribelle Lacno

 * Program name:    cube

 * Subject:               IT134_Computer Programming 3

 * Instructor:            Mr. Dony Dongiapon

 * Date Started:        02/04/09

 * Date Finished:       02/04/09

 * Purpose:              To create a class that will calculate the volume

 *                                 and area of a  cube inside a private methods.

*/

import javax.swing.JOptionPane;

public class cube{

  private double width;
  private double height;
  private double length;
  private double totalVolume;
  private double totalArea;
    
  //declare a constructor cube with a parameters.
  public cube(double newWidth, double newHeight, double newLength){
   width = newWidth;
   length = newLength;
   height = newHeight;
      
   this.volume();
   this.area();
  }
   
  //declare a constructor cube without a parameters.
  public cube(){
   double newWidth = Integer.parseInt(JOptionPane.showInputDialog("Enter a new width:"));
   double newHeight = Integer.parseInt(JOptionPane.showInputDialog("Enter a new height:"));
   double newLength = Integer.parseInt(JOptionPane.showInputDialog("Enter a new length:"));
        
   this.setDimension(newWidth, newHeight,newLength);
   this.volume();
   this.area();
  }
   
  //create a private method that will calculate and return the volume of a cube.
  private double volume(){
   return totalVolume = length*width*height;
  }
    
  //create a private method that will calculate and return the area of a cube.
  private double area(){
   return totalArea = length*width;
  }
    
  //set a new dimension of your cube
  public void setDimension(double newWidth, double newHeight, double newLength){
   width = newWidth;
   height = newHeight;
   length = newLength;
  }
    
  //display the volume and area of your cube
  public void displayCube(){
   JOptionPane.showMessageDialog(null,"The volume of your cube is "+totalVolume+"\n                  and the area of your cube is "+totalArea);
  }  
   
}

cubeTester

/* Programmer:     Maribelle Lacno
  *Program name:  cubeTester
  *Subject:               IT134_Computer Programming 3
  *Instructor:          Mr. Dony Dongiapon
  *Date Started:      02/04/09
  *Date Finished:    02/04/09
  *Purpose:              To create a cubeTester class that will access                                                             *                               the private methods of the cube class.
*/

public class cubeTester{

 public static void main(String[] args){
      
  cube myCube = new cube(5.0,5.0,5.0);
  myCube.displayCube();
        
  cube myNewCube = new cube();
  myNewCube.displayCube();
 }
   
}