Java Programming Home Page: Archive: Message #36

Date: Feb 17 2000 17:50:51 EST
From: "Java Programming" <javaProgramming-owner@listbot.com>
Subject: Making a customer list

hi All,
Suppose you want an unlimited number of customers...
Each customer can be printed. So, you use a vector:
import java.util.Vector;
public class CustomerVector implements Printable {
	private Vector v = new Vector();
	
	public void init() {
		v.addElement(new NamedCustomer("Frank",100000)); 
		v.addElement(new NamedCustomer("Rob",50000));
		v.addElement(new NamedCustomer("Velma",999999));
	}
	
	public static void main(String args[]){
		CustomerVector cv = new CustomerVector();
		cv.print();
	}
	public void print() {
		for (int x=0; x < v.size(); x++) 
			((Printable)v.elementAt(x)).print();
	}
}