FileDocCategorySizeDatePackage
MediaInvoicer.javaAPI DocExample2295Sun Mar 07 21:31:00 GMT 2004None

MediaInvoicer

public class MediaInvoicer extends Object
MediaInvoicer - Simple applicatin of Media, MediaFactory &c.
author
ian
version
$Id: MediaInvoicer.java,v 1.2 2004/03/08 03:30:59 ian Exp $

Fields Summary
BufferedReader
myFile
Constructors Summary
public MediaInvoicer(InputStream is)

		myFile = new BufferedReader(new InputStreamReader(is));
	
Methods Summary
public MediaInvoicer$InvoicegetInvoice()

		String line;
		List < Item > items = new ArrayList < Item > ();
		while ((line = myFile.readLine()) != null) {
			if (line.startsWith("#")) {
				continue;
			}
			StringTokenizer st = new StringTokenizer(line);
			st.nextToken();
			Media m = MediaFactory.getMedia(st.nextToken());
			int stock = Integer.parseInt(st.nextToken());
			int qty = Integer.parseInt(st.nextToken());
			Item tmp = new Item(m, stock, qty);
			items.add(tmp);
		}
		return new Invoice(1, 3,
			(Item[]) items.toArray(new Item[items.size()]));
	
public static voidmain(java.lang.String[] args)

		MediaInvoicer mi = new MediaInvoicer(System.in);
		Invoice i = mi.getInvoice();
		i.print(System.out);