Sunday, February 8, 2009

Objects in the Direct Clothing Case Study

/**Programmer Name: Besas, Jhovan C.
   Program Name: Direct Clothing Case Study
   Purpose: To apply knowledge that i have learned in OOP.
   Date: February 8, 2009
   Subect: Computer Programming 3
   Instructor: Dony Dongiapon**/

public class Customer{ Int CustomerID; String Name; String Address; int phoneNumber; String EmailAdd;

public Customer(int newcustomerID, string newname, String newAddress, int newPhoneNumber, string newEMail) { this.CustomerID=newcustomerID; this.Name=newname; this.Address=newAddress; this.phoneNumber=newPhoneNumber; this.EmailAddress=newEMail; }
public String displayInformation() { return String.format(CustomerID,Name,Address,phoneNumber,EmailAdd); } }


____________________________________________________________
public class Shirt { Int shirtID; double price; String color; String Sdescription; int Squantity;
public Shirt(int newID, double newprice, String newCcolor, String newdescription, int newquantity) { shirtID=newID; price=newprice; color=newCcolor; description=newdescription; quantity=newquantity; } Public shirt() { }public int addStock() { return quantity=quantity+stock; }
public int removeStock() { return quantity=quantity-stock; }
public String displayInformation() { return String.format("The following are the current information of the shirt"shirtID,price,color,description,quantity); } }


___________________________________________________
public class Order{ Int OrderID; double TotaPrice;; String status; public Order(int newID, double newTotalPrice, String newStatus) { OrderID=newID; TotalPrice=newTotalPrice; status=newStatus; }
public String displayInformation() { return String.format(OrderID,TotalPrice,status); } }

Wednesday, February 4, 2009

Programming 3

/* Programmer: Besas, Jhovan
  Program name: Cube
  Subject: IT134A_Computer Programming 3
  Instructor: Mr. Dony Dongiapon
  Date Started: Febuary 04,2009
  Date Finished: Febuary 04,2009
  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 vwidth;
 private double vlength;
 private double vheight;
 private double vvolume;
 private double varea;
 

 

 public Cube(double width, double height, double length)

 {
  this.vwidth=width;
  this.vheight=height;
  this.vlength=length;
 }

 public Cube()

 {
  
 }

 private double volume()

  {
  return (vwidth*vlength*vheight); 
  
  }


 private double area()

  {
  
  return (vwidth*vlength); 
  
  }
 

 public void setDimension(double newwidth, double newheight, double newlength)

 {
  this.vwidth=newwidth;
  this.vheight=newheight;
  this.vlength=newlength;
 }

 public String displayCube()

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

}
 



/* Programmer: Besas, Jhovan
  Program name: CubeTester
  Subject: IT134A_Computer Programming 3
  Instructor: Mr. Dony Dongiapon
  Date Started: Febuary 04,2009
  Date Finished: Febuary 04,2009
  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 Cubex=new Cube(2,8,4);
  Cube Cubey=new Cube();
  
 

  
JOptionPane.showMessageDialog(null,"The volume and area having a parameter is: "+Cubex.displayCube(),
  "Volume and Area of a Cube",JOptionPane.PLAIN_MESSAGE);

JOptionPane.showMessageDialog(null,"Lets proceed to the constructor without a parameter.."); 
   
 String w=JOptionPane.showInputDialog("Kindly enter the value of width: ");
 String h=JOptionPane.showInputDialog("Kindly enter the value of height: ");
 String l=JOptionPane.showInputDialog("Kindly enter the value of lenght: ");

  double h=Integer.parseInt(w);
  double i=Integer.parseInt(h);
  double j=Integer.parseInt(l);

Cubey.setDimension(h,i,j);

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

}
}