Wednesday, March 4, 2009
Iterator arrayList
Program name : Iterators
Date Started : March 2,2009
Date Finished : March 3,2009
Purpose : Iterate through elements Java ArrayList using Iterator
Instructor : Dony Dongiapon
Subject : IT134
*/
package collection;
import java.util.ArrayList;
import java.util.Iterator;
public class IteratorDemo {
public static void main(String arg[])
{
ArrayList reu=new ArrayList();
for(int i=0;i<10;i++)
{
reu.add(new Integer(i));
}
System.out.println(reu); // 0,1,2,3,……9
Iterator itr=reu.iterator();
while(itr.hasNext())
{
Integer i=(Integer)itr.next();
if(i.intValue() % 2==0)
{
System.out.println(i);
}
else
{
itr.remove();
}
}
}
}
output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
0
2
4
6
8
Source: http://www.javaexamples4u.com/2009/02/iterator-source-code.html
I learned that iterator is an object representing a stream of data. Repeated calls to the iterator’s next() method return successive items in the stream. When no more data is available a StopIteration exception is raised.
***********************************************************************
Monday, February 9, 2009
Case Study of Direct Clothing
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
private int CustomerID;
public String Name;
public int PhoneNumber;
publicString Address;
publicString Emailaddress;
//This is a Customer constructor
public Customer ( int newCustomerID, String newName, String newAddress, String newEmailaddress)
{
CustomerID = newCustomerID;
Name = newName;
PhoneNumber = newPhoneNumber;
Address = newAddress;
Emailaddress =newEmailaddress;
}
}
-----------------------------------------------------------------
/* Pogrammer Name : Reuben Matiga
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
public class Order extends Customer{
public String OrderID;
public int TotalPrice;
public String Status;
// Order Constructor
public Order (int newCustomerID, String newName, String newAddress, String newEmailaddress, String newOrderID,int TotalPrice, String Status )
{
super(int newCustomerID, String newName, String newAddress, String newEmailaddress);
OrderID = newOrderID;
TotalPrice = newTotalPrice;
Status = newStatus;
}
}
----------------------------------------------------------
/* Pogrammer Name : Reuben Matiga
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
public class Shirt extends Customer{
public String ShirtID;
public int Price;
public String Color;
public String Description;
public int Quantity;
// Shirt constructor
public Shirt(int newCustomerID, String newName, String newAddress, String newEmailaddress, String newShirtID, int newPrice, String newColor, String newDescription,int newQuantity )
{
super(int newCustomerID, String newName, String newAddress, String newEmailaddress);
ShirtID = newShirtID;
Price = newPrice;
Color = newColor;
Description = newDescription;
Quantity = newQuantity;
}
}
-----------------------------------------------
/* Pogrammer Name : Reuben Matiga
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
public class FormOfPayment extends Customer{
public int ChckNumber;
public int CrdtCrdNumber;
public double ExpirationDate;
// Form of Payment Constructor
public FormOfPayment(int newCustomerID, String newName, String newAddress, String newEmailaddress, int newChckNumber, int newCrdtCrdNumber,double newExpirationDate )
{
super(int newCustomerID, String newName, String newAddress, String newEmailaddress);
ChckNumber = newChckNumber;
CrdtCrdNumber = newCrdtCrdNumber;
ExpirationDate = newExpirationDate;
}
}
----------------------------------------------------------------------
/* Pogrammer Name : Reuben Matiga
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
public class Catalog extends Shirt{
public Catalog(int newCustomerID, String newName, String newAddress, String newEmailaddress, int newChckNumber, int newCrdtCrdNumber,double newExpirationDate )
{
super(String newShirtID, int newPrice, String newColor, String newDescription,int newQuantity );
}
}
---------------------------------------------------------
/* Pogrammer Name : Reuben Matiga
Date Started : 02-06-09
Date Finished : 02-08-09
Program Name : Direct Clothing Case Study
Program Purpose : To have a solution in case study
*/
public class CustomerDemo{
public static void main(String [] args){
}
}
