Wednesday, March 18, 2009
Direct Clothing
private String ShirtID;
private double Price;
private String Color;
private String Description;
private int Quantity;
public shirt (String TShirtID, double TPrice, String TColor, String TDescription, int TQuantity){
ShirtID=TShirtID;
Price=TPrice;
Color=TColor;
Description=TDescription;
Quantity=TQuantity;
}
public void setShirtID( String TShirtID){
ShirtID=TShirtID;
}
public String getShirtID(){
return ShirtID;
}
public void setPrice( double TPrice){
Price=TPrice;
}
public double getPrice(){
return Price;
}
public void setColor( String TColor){
Color=TColor;
}
public String getColor(){
return Color; }
public void setDescription( String TDescription){
Description=TDescription;
}
public String getDescription(){
return Description;
}
public void setQuantity( int TQuantity)
{
Quantity=TQuantity;
}
public int getQuantity(){
return Quantity;
}
}
public class Customer{
private int CustomerID;
private String Name;
private String Address;
private int PhoneNum;
private String EmailAdd;
public Customer(){ }
public void Customer(int TCustomerID,String TName, String TAddress, int TPhoneNum, String TEmailAdd){
CustomerID=TCustomerID;
Name=TName;
Address=TAddress;
PhoneNum=TPhoneNum;
EmailAdd=TEmailAdd;
System.out.println ("CustomerID:"+CustomerID+"\nNAME:"+Name+"\nAddress:"+Address+"\nPhoneNum."+PhoneNum+"\nE-mail Address:"+EmailAdd);
}
}
public class Order{
private String OrderID;
private double TotalPrice;
private String Status;
public Order(){ }
public void Shirts(String TOrderID, double TTotalPrice, String TStatus)
{
String OrderID = TOrderID;
double TotalPrice=TTotalPrice;
String Status=TStatus;
}
public void setOrderID(String TOrderID)
{ String OrderID=TOrderID;
}
public String getOrderID(){ return OrderID; } public void setTotalPrice(double TTotalPrice){
String TotalPrice=TTotalPrice;
}
public String getTotalPrice()
{
return TotalPrice;
}
public void setStatus(String TStatus){
String Status=TStatus;
}
public String getStatus(){
return Status;
}
}
public class Payment{
private String CheckNum;
private String CCardNum;
private String ExpDate;
public Payment(String TCheckNum, String TCCardNum, String TExpDate ){
String CheckNum=TCheckNum;
String CCardNum=TCCardNum;
String ExpDate=TExpDate;
}
public void setCheckNum(String TCheckNum){
String CheckNum=TCheckNum;
}
public String getCheckNum(){
return CheckNum;
}
public void setCCardNum(String TCCardNum){
String CCardNum=TCCardNum;
}
public String getCCardNum(){
return CCardNum;
}
public void setExpDate (String TExpDate ){
String ExpDate =TExpDate ;
}
public String getExpDate (){
return ExpDate ;
}
public void Check(){
System.out.println("Check number is:%s")
}
}
public class Catalog{
private String shirt;
public void addShirt(String newShirt) {shirt=newShirt;
}
public void removedShirt(String deleteShirt)
{shirt=deleteShirt;
}
}
import java.util.Scanner;
public class Tester{
public static void main ( String [] args){
Scanner x = new Scanner(System.in);
shirt TheShirt= new shirt();
System.out.println(" choose on our catalog ");
TheShirt.displayCatalog();
Scanner x=new Scanner(System.in);
System.out.println("Do you have your choice?");
if(x=='y') {
System.out.println("Enter ShirtID:");
String ID=x.nextLine(); TheShirt.setShirtID(ID);
System.out.println();
System.out.println("Enter Price:");
double price=x.nextDouble();
TheShirt.setPrice(price);
System.out.println();
System.out.println("Enter Color:");
String color=x.nextLine();
TheShirt.setColor(color);
System.out.println();
System.out.println("Enter Quantity:");
int Tquantity=x.nextInt();
TheShirt.setQuantiy(Tquantity);
System.out.println();
System.out.println(" Enter Shirt Description:");
String TheDescription=x.nextLine();
TheShirt.setDescription(TheDescription);
System.out.println(); System.out.println("Choose successfully");
}
else{
System.out.println("OK");
}
}
}
Cube
public class Cube{
Tuesday, March 10, 2009
User-Friendly Division
/*
Programmer: Mary Rose M. Celmar
Date Started: 03-11-09
Date Ended: 03-11-09
*/
import java.util.*;
public class Division{
public static void main(String [] args){
Scanner x=new Scanner (System.in);
String word;
for (int b=0; b<=3; b++){
int y;
System.out.print( "Enter Numerator :");
y=x.nextInt();
int z;
System.out.print( "Enter Denaminator :");
z=x.nextInt();
int a=y/z;
System.out.print( "The Answer is :"+a);
System.out.println();
if (a==0){
System.out.print( "You can't divide it by zero "+"Please Try Again");
}else {
word=x.next();
char w=word.charAt(0);
System.out.println( "You enter bad data");
System.out.println( "Please try again");
System.out.println();
}
}
}
}
Tuesday, March 3, 2009
Iterator
/*
Programmer: Mary Rose M. Celmar
Date Started: 03-04-09
Date Ended: 03-04-09
Purpose: to learn about iterator
*/
class WithData{
private Treeset<>m_data=new Treeset
public void add(int in)
{
m_data.add(in);
}
public Collection get_data()
{
return m_data;
}
}
class Demo{
public static void main (String [] args){
WithData some_object=new WithData ();
for (int i=9;i>0;--1)
some_object.add(i);
Collection data =some_object.get_data();
for (java.util.Iterator it=data.iterator();it.hasNext();)
System.out.print(it.next() + " ");
}
}
output:
1 2 3 4 5 6 7 8 9
I Learned about:
* three methods of iterator which is optional. The it.hasNext(), it.next(), and it.remove().
* Iterator are created by calling the iterator() or listIterator() method.
* listIterator Methods . the it.hasPrevious(), it.previous(),itnextIndex(), it.previousIndex(), it.add(obj), it.set(),and it.remove()