import sale.*;
import log.*;
import users.*;
import data.*;
import data.ooimpl.*;
import java.io.*;
import java.util.*;
import java.lang.*;
public class VideoMachine extends Shop
{
private static Set customerSet = new HashSet();
public VideoMachine()
{
super();
String[] videos = {"Video 01", "Video 02", "Video 03", "Video 04",
"Video 05", "Video 06", "Video 07", "Video 08",
"Video 09", "Video 10"};
int[] buy = {5000, 5000, 5000, 5000, 5000, 4000, 4000, 4000, 3000, 3000};
int[] sell = {4000, 4000, 4000, 4000, 3500, 3500, 3500, 3500, 3000, 3000};
Catalog videoCatalog = new CatalogImpl("Video-Catalog");
addCatalog(videoCatalog);
for (int i = 0; i < videos.length; i++) {
videoCatalog.add(new VideoCassette (videos[i], new QuoteValue
(new IntegerValue (buy[i]), new IntegerValue (sell[i]))), null);
}
CountingStock cs = new CountingStockImpl("Video-Countingstock",
(CatalogImpl)videoCatalog);
addStock(cs);
Iterator cassettes = videoCatalog.keySet(null).iterator();
while (cassettes.hasNext()) {
cs.add((String)cassettes.next(), 5, null);
}
addCatalog(new CurrencyImpl("DM"));
MoneyBag coinSlot = new MoneyBagImpl("coin slot",
(CurrencyImpl)getCatalog("DM"));
coinSlot.add(CurrencyImpl.PFENNIG_STCK_1, 100000, null);
addStock(coinSlot);
}
public static void main (String[] args)
{
VideoMachine vidMachine = new VideoMachine();
setTheShop(vidMachine);
Counter c = new Counter("Video Rental");
c.attach(new DataBasketImpl());
c.attach(new User("SalespointUser"));
vidMachine.addSalesPoint(c);
vidMachine.setShopFrameTitle("Videoverleihautomat *** HOMECINEMA *** 24h");
vidMachine.start();
vidMachine.getShopFrame().setSize(640,480);
vidMachine.getShopFrame().validate();
}
public void quit()
{
if (Shop.getTheShop().shutdown (false)) {
System.exit (0);
}
}
public static void addCustomer(Customer customer)
{
customerSet.add(customer);
}
public static void removeCustomer(Customer customer)
{
customerSet.remove(customer);
}
public static Set getAllCustomer()
{
return customerSet.isEmpty() ? null : customerSet;
}
public static Customer getCustomerByID(String customerID)
{
Iterator i = customerSet.iterator();
while (i.hasNext()) {
Customer customer = (Customer)i.next();
if (customer.getCustomerID().equals(customerID))
return customer;
}
return null;
}
}