Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.HashMap;
- import java.util.Iterator;
- import com.menonthemoon.lagerVerwaltung.Configuration;
- import com.menonthemoon.lagerVerwaltung.Product;
- import com.menonthemoon.lagerVerwaltung.ProductGroup;
- import com.menonthemoon.lagerVerwaltung.Stock;
- import com.menonthemoon.lagerVerwaltung.StockException;
- import com.menonthemoon.lagerVerwaltung.StockManager;
- public class Test {
- private static String c = ":> ";
- static double nPrices[] = {40.0 , 70.0, 10.0, 50.0, 75.0, 100.0, 120.0, 330.0, 100.0, 140.0, 120.0, 100.0, 50.0, 220.0, 180.0, 50.0, 40.0, 50.0, 70.0, 20.0, 20.0};
- static double salesPrices[] = {80.0, 140.0, 15.0, 75.0, 110.0, 150.0, 180.0, 550.0, 140.0, 180.0, 165.0, 140.0, 90.0, 340.0, 210.0, 90, 70.0, 80.0, 110.0, 40.0, 40.0};
- static double warehouseCharges[] = {1.0, 1.0, 0.5, 10.0, 20.0, 0.5, 0.5, 1.0, 1.0, 2.0, 2.0, 0.5, 0.5, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 0.5, 0.5};
- private static Product[] products = {
- new Product("Samsung Rx1213 CD-Laufwerk", "CD-Rom 52x",new BigDecimal(nPrices[0]),salesPrices[0],warehouseCharges[0]), // #0
- new Product("BD-R/BD-RE Laufwerk SATA LG BH08LS, Blu-ray, Bulk ",
- "Schwarz",new BigDecimal(nPrices[1]),salesPrices[1],warehouseCharges[1]),
- new Product("Mitsubishi F12 Floppy-Laufwerk", "Floppy Disc"),
- // - cases
- new Product("Chieftech Mini Tower", "Small PC-case",new BigDecimal(nPrices[2]),salesPrices[2],warehouseCharges[2]),
- new Product("Chieftech Big Tower", "Big PC-case",new BigDecimal(nPrices[3]),salesPrices[3],warehouseCharges[3]),
- // - processors
- new Product("AMD Athlon (S-AM2+)",
- "Prozessor AMD Athlon X2 7850 Black Edition, 2,8GHz, Dual-Core, S-AM2+, Tray",new BigDecimal(nPrices[4]),salesPrices[4],warehouseCharges[4]),
- new Product("Intel Atom D510 (Dual-Core) / 1,67 GHz",
- "Intel Atom, Engery efficient", new BigDecimal(nPrices[5]),salesPrices[5],warehouseCharges[5]),
- // - hdd
- new Product("Seagate, 320 GB HDD, SSD", "SolidStateDisk", new BigDecimal(nPrices[6]),salesPrices[6],warehouseCharges[6]),
- new Product("Western Digital, 1 TB HDD, SATA", "A lot of space",new BigDecimal(nPrices[7]),salesPrices[7],warehouseCharges[7]),
- // - mainboard
- new Product("S-462 ASROCK K7S41GX", "AMD Mainboard, Socket 462",new BigDecimal(nPrices[8]),salesPrices[8],warehouseCharges[8]),
- new Product("GIGABYTE GA-P55-UD5, ATX", // #10
- "INTEL Mainboard, Socket 1156",new BigDecimal(nPrices[9]),salesPrices[9],warehouseCharges[9]),
- // - RAM
- new Product("DDR3-RAM", "4GB",new BigDecimal(nPrices[10]),salesPrices[10],warehouseCharges[10]),
- new Product("DDR2-RAM", "4GB",new BigDecimal(nPrices[11]),salesPrices[11],warehouseCharges[11]),
- // -graficsCard
- new Product("PCI-E 2.0 ASUS Extreme AH4350", "PCI-e",new BigDecimal(nPrices[12]),salesPrices[12],warehouseCharges[12]),
- new Product("AGP 8x MATROX QID, 128MB", "AGP",new BigDecimal(nPrices[13]),salesPrices[13],warehouseCharges[13]),
- // -cooling
- new Product("COOLER MASTER Hyper 212 Plus", "Socket 1156",new BigDecimal(nPrices[14]),salesPrices[14],warehouseCharges[14]),
- new Product("CORSAIR A50 Performance", "Socket 462",new BigDecimal(nPrices[15]),salesPrices[15],warehouseCharges[15]),
- // -acSupply
- new Product("510 Watt, ZIPPY P2G-6510P, 2HE, EPS12V", "510 Watt",new BigDecimal(nPrices[16]),salesPrices[16],warehouseCharges[16]),
- new Product("ATX 600 Watt, ENERMAX PRO87+, 80Plus-Gold",
- "ATX 600 Watt",new BigDecimal(nPrices[17]),salesPrices[17],warehouseCharges[17]),
- // -networking
- new Product("PCI Intel PRO/100GT", "PCI, 10/100 MBit",new BigDecimal(nPrices[18]),salesPrices[18],warehouseCharges[18]),
- new Product("PCI-E INTEL Pro 1000 ", "PCI-E, 10/100/1000 MBit",new BigDecimal(nPrices[19]),salesPrices[19],warehouseCharges[19]) // #20
- };
- private static int[] amounts = { 12, 15, 6, 17, 22, 8, 13, 4, 11, 7, 12,
- 25, 34, 7, 9, 22, 23, 39, 21, 6, 11 };
- private static Stock stock;
- public static String addProducts() {
- boolean retVal = true;
- for (int i = 0; i < products.length; i++) {
- retVal &= testAdd(products[i], amounts[i]);
- }
- // increase amount:
- retVal &= testAdd(products[0], amounts[0]);
- retVal &= testAdd(products[20], 0);
- retVal &= testAdd(products[5], -1) == false;
- return retVal ? "SUCCESS" : "FAIL";
- }
- public static boolean testAdd(Product p, int a) {
- Integer oldVal, newVal;
- try {
- oldVal = stock.add(p, a);
- } catch (StockException e) {
- return false;
- }
- if (oldVal == null) {
- oldVal = new Integer(0);
- }
- newVal = stock.getStock(p);
- if (newVal.intValue() == oldVal.intValue() + a) {
- return true;
- }
- return false;
- }
- public static String testTake() {
- Integer before, after;
- before = stock.getStock(products[0]);
- try {
- stock.take(products[0], 1);
- } catch (StockException e) {
- // TODO Auto-generated catch block
- }
- after = stock.getStock(products[0]);
- if (after.intValue() == before.intValue() - 1) {
- return "SUCCESS";
- }
- return "FAIL";
- }
- public static String testRemove() {
- try {
- if (stock.getStock(products[0]) != null) {
- stock.remove(products[0]);
- }
- if (stock.getStock(products[0]) == null) {
- stock.add(products[0], amounts[0]);
- return "SUCCESS";
- }
- } catch (StockException e) {
- }
- return "FAIL";
- }
- public static String testOrdering() {
- Product p = products[0];
- /*
- * Import one product to the stock at 22.12.2010
- */
- int initialStock = stock.getStock(p);
- Date importDate = new GregorianCalendar(2010, Calendar.DECEMBER, 22).getTime();
- int importAmount = 1;
- System.out.print("\tImport a product at "+importDate.toString());
- try {
- stock.importProduct(p, importAmount, importDate);
- } catch (StockException e1) {
- System.out.println("[error] Fehler beim import: "+e1.getMessage());
- }
- int modifiedStock = stock.getStock(p, new GregorianCalendar(2010, Calendar.DECEMBER, 23).getTime());
- String result = (modifiedStock == initialStock + importAmount) ? "SUCCESS" : "FAIL";
- System.out.println("\t"+result);
- try {
- Date exportDate = new GregorianCalendar(2010,Calendar.DECEMBER, 23).getTime();
- // export exportAmount products from the stock at exportDate
- System.out.print("\tExport a product with enough items in stock at "+exportDate.toString());
- stock.exportProduct(p, 10, exportDate);
- System.out.println("\tSUCCESS");
- System.out.println("\tExport a product with too little items in stock at "+exportDate.toString());
- stock.exportProduct(p, 1000, exportDate);
- } catch (StockException e) {
- System.out.print("\t[error] "+e.getMessage());
- }
- return "SUCCESS";
- }
- public static String testMove() {
- /*
- * Move one product from a stock to another stock
- */
- Product p = products[1];
- Stock affiliate = StockManager.sharedInstance().getAffiliateStocks().iterator().next();
- int initialMainStock = stock.getStock(p);
- int intialAffiliateStock = affiliate.getStock(p);
- int amountToMove = 3;
- if(!StockManager.sharedInstance().getAffiliateStocks().isEmpty()) {
- try {
- stock.moveProduct(p, amountToMove, affiliate, null);
- } catch(StockException e) {
- System.out.println(c + "Das Produkt kann nicht verschoben werden: "+e.getMessage());
- }
- }
- int postMainStock = stock.getStock(p);
- int postAffiliateStock = affiliate.getStock(p);
- System.out.println("\tInitial main stock amount of product: "+initialMainStock +
- "; Post-Move amount of product: "+postMainStock);
- System.out.println("\tInitial affiliate stock amount of product: "+intialAffiliateStock +
- "; Post-Move amount of product: "+postAffiliateStock);
- return (postMainStock == initialMainStock - amountToMove && postAffiliateStock == intialAffiliateStock + amountToMove) ?
- "SUCCESS" : "FAIL";
- }
- public static void main(String[] args) {
- performAssignment2();
- }
- private static void performAssignment2() {
- String welcome = "=========================================================================\n"
- + "OOP (VL Objektorientierte Programmierung)\n"
- + "\tAufgabe #2\n"
- + "Gruppe:\n"
- + "\t229\n"
- + "Teilnehmer:\n"
- + "\tALEXANDER WOLF e0102124@student.tuwien.ac.at\n"
- + "\tDANIEL REICHHARD e0025792@student.tuwien.ac.at\n"
- + "\tAUGUST NIKOLAUS KAMPFER e0326465@student.tuwien.ac.at\n"
- + "=========================================================================\n";
- System.out.println(welcome);
- // create a new main stock and one affiliate stock
- StockManager sm = StockManager.sharedInstance();
- sm.setMainStock(new Stock());
- sm.addAffiliateStock(new Stock());
- stock = sm.getMainStock();
- System.out.println("TEST: Adding products\t\t" + addProducts());
- System.out.println("TEST: Taking products\t\t" + testTake());
- System.out.println("TEST: Removing products\t\t" + testRemove());
- System.out.println("TEST: Importing product at a given date\t\t");
- System.out.println(testOrdering());
- System.out.println("TEST: Moving products from one stock to another one\t\t");
- System.out.println(testMove());
- Product p = products[0];
- ProductGroup g1 = new ProductGroup("Internal Optical Drives");
- g1.add(products[0]);
- g1.add(products[20]);
- stock.add(g1);
- try {
- System.out.println(c
- + "Entferne Produkt aus dem Lager, alter Bestand war: "
- + stock.remove(products[0]));
- } catch (StockException e) {
- System.out.println(e.getMessage());
- }
- Configuration c1 = new Configuration("Business Desktop PC, small",999.0,9.0);
- c1.add(products[1], 1);
- c1.add(products[2], 1);
- c1.add(products[3], 1);
- c1.add(products[4], 1);
- c1.add(g1, 12);
- System.out.println(c + "Konfiguration: " + c1.getName()
- + " wurde erstellt und enthält folgende Produkte:");
- HashMap<Product, Integer> productMap = c1.getConfiguration();
- Iterator<Product> it = productMap.keySet().iterator();
- while (it.hasNext()) {
- Product p1 = it.next();
- System.out.println(c + "\t" + p1.getName() + " ("
- + productMap.get(p1) + " Stk.; Lagerbestand: "
- + stock.getStock(p1) + ")");
- }
- }
- private static void performAssignment1() {
- String welcome = "=========================================================================\n"
- + "OOP (VL Objektorientierte Programmierung)\n"
- + "\tAufgabe #1\n"
- + "Gruppe:\n"
- + "\t229\n"
- + "Teilnehmer:\n"
- + "\tALEXANDER WOLF e0102124@student.tuwien.ac.at\n"
- + "\tDANIEL REICHHARD e0025792@student.tuwien.ac.at\n"
- + "\tAUGUST NIKOLAUS KAMPFER e0326465@student.tuwien.ac.at\n"
- + "=========================================================================\n";
- String taskA = "A.) Anlegen von Produkten, wobei jedes Produkt einen eindeutigen \n\tNamen und eine Beschreibung erhaelt.\n";
- String taskB = "B.) Erhoehen und Verringern des Lagerbestandes (= Anzahl der vorhandenen\n\tStuecke)sowie Abfragen des Lagerbestandes und aller weiteren \n\tDaten zu einem Produkt.\n";
- String taskB1 = "B.1) Der Lagerbestand von einigen Produkten wird entsprechend verringert\n";
- String taskC = "C/D/E) \n\tAnlegen von Produktgruppen (wie z.B. Prozessoren, Festplatten und Hauptspeicher).\n"
- + "\tZuordnen von Produkten und Produktgruppen zu (anderen) Produktgruppen \n\t(wie z.B. von X zur Produktgruppe DVD-Brenner und von DVD-Brenner \n\tzur Produktgruppe Optische Laufwerke), wobei Produkte und Produktgruppen auch \n\tmehreren (anderen) Produktgruppen zugeordnet sein koennen.\n"
- + "\tAuflisten aller Produkte einer Produktgruppe einschlieszlich Lagerbestand, \n\twobei auch alle Produkte aller zugeordneten Produktgruppen aufgelistet werden \n\t(z.B. auch der DVD-Brenner X in der Auflistung von Optische Laufwerke)\n";
- String taskF = "F.) Anlegen von Konfigurationen, die gegebene Stueckzahlen bestimmter Produkte \n\tunter neuen Namen zusammenfassen (wie z.B. 1 Gehaaeuse G, 1 Mainboard M, 2 \n\tHauptspeicher R und 2 Festplatten H zur Konfiguration Komplettsystem1)\n";
- String taskG = "G.) Abfragen des Lagerbestands fuer eine Konfiguration, wobei ermittelt wird,\n\twie viele entsprechend konfigurierte Geraete aus dem Lagerbestand zusammengebaut werden koennen.\n";
- String taskH = "H.) Verringern des Lagerbestands aller Produkte, die fuer eine bestimmte \n\tAnzahl an Geraeten einer bestimmten Konfiguration benoetigt werden\n";
- System.out.println(welcome);
- System.out.println(c + "Erstellung einer Lagerinstanz.\n");
- // Create the new Stock
- Stock stock = new Stock();
- // Create all available products
- // - internal drives
- System.out.println(c + taskA);
- Product p1 = new Product("Samsung Rx1213 CD-Laufwerk", "CD-Rom 52x");
- System.out.println(c + "Produkt: " + p1.getName() + " wurde erstellt");
- Product p21 = new Product(
- "BD-R/BD-RE Laufwerk SATA LG BH08LS, Blu-ray, Bulk ", "Schwarz");
- System.out.println(c + "Produkt: " + p21.getName() + " wurde erstellt");
- Product p2 = new Product("Mitsubishi F12 Floppy-Laufwerk",
- "Floppy Disc");
- System.out.println(c + "Produkt: " + p2.getName() + " wurde erstellt");
- // - cases
- Product p3 = new Product("Chieftech Mini Tower", "Small PC-case");
- System.out.println(c + "Produkt: " + p3.getName() + " wurde erstellt");
- Product p4 = new Product("Chieftech Big Tower", "Big PC-case");
- System.out.println(c + "Produkt: " + p4.getName() + " wurde erstellt");
- // - processors
- Product p5 = new Product("AMD Athlon (S-AM2+)",
- "Prozessor AMD Athlon X2 7850 Black Edition, 2,8GHz, Dual-Core, S-AM2+, Tray");
- System.out.println(c + "Produkt: " + p5.getName() + " wurde erstellt");
- Product p6 = new Product("Intel Atom D510 (Dual-Core) / 1,67 GHz",
- "Intel Atom, Engery efficient");
- System.out.println(c + "Produkt: " + p6.getName() + " wurde erstellt");
- // -hdd
- Product p7 = new Product("Seagate, 320 GB HDD, SSD", "SolidStateDisk");
- System.out.println(c + "Produkt: " + p7.getName() + " wurde erstellt");
- Product p8 = new Product("Western Digital, 1 TB HDD, SATA",
- "A lot of space");
- System.out.println(c + "Produkt: " + p8.getName() + " wurde erstellt");
- // -mainboard
- Product p9 = new Product("S-462 ASROCK K7S41GX",
- "AMD Mainboard, Socket 462");
- System.out.println(c + "Produkt: " + p9.getName() + " wurde erstellt");
- Product p10 = new Product("GIGABYTE GA-P55-UD5, ATX",
- "INTEL Mainboard, Socket 1156");
- System.out.println(c + "Produkt: " + p10.getName() + " wurde erstellt");
- // -RAM
- Product p11 = new Product("DDR3-RAM", "4GB");
- System.out.println(c + "Produkt: " + p11.getName() + " wurde erstellt");
- Product p12 = new Product("DDR2-RAM", "4GB");
- System.out.println(c + "Produkt: " + p12.getName() + " wurde erstellt");
- // -graficsCard
- Product p13 = new Product("PCI-E 2.0 ASUS Extreme AH4350", "PCI-e");
- System.out.println(c + "Produkt: " + p13.getName() + " wurde erstellt");
- Product p14 = new Product("AGP 8x MATROX QID, 128MB", "AGP");
- System.out.println(c + "Produkt: " + p14.getName() + " wurde erstellt");
- // -cooling
- Product p15 = new Product("COOLER MASTER Hyper 212 Plus", "Socket 1156");
- System.out.println(c + "Produkt: " + p15.getName() + " wurde erstellt");
- Product p16 = new Product("CORSAIR A50 Performance", "Socket 462");
- System.out.println(c + "Produkt: " + p16.getName() + " wurde erstellt");
- // -acSupply
- Product p17 = new Product("510 Watt, ZIPPY P2G-6510P, 2HE, EPS12V",
- "510 Watt");
- System.out.println(c + "Produkt: " + p17.getName() + " wurde erstellt");
- Product p18 = new Product("ATX 600 Watt, ENERMAX PRO87+, 80Plus-Gold",
- "ATX 600 Watt");
- System.out.println(c + "Produkt: " + p18.getName() + " wurde erstellt");
- // -networking
- Product p19 = new Product("PCI Intel PRO/100GT", "PCI, 10/100 MBit");
- System.out.println(c + "Produkt: " + p19.getName() + " wurde erstellt");
- Product p20 = new Product("PCI-E INTEL Pro 1000 ",
- "PCI-E, 10/100/1000 MBit");
- System.out.println(c + "Produkt: " + p20.getName()
- + " wurde erstellt\n");
- /*
- * Add the products to the stock and set their amount number
- */
- System.out.println(c + taskB);
- try {
- stock.add(p1, 12);
- System.out.println(c + "Lagerbestand von: " + p1.getName() + " auf \""
- + stock.getStock(p1) + "\" erhöht");
- stock.add(p2, 15);
- System.out.println(c + "Lagerbestand von: " + p2.getName() + " auf \""
- + stock.getStock(p2) + "\" erhöht");
- stock.add(p3, 6);
- System.out.println(c + "Lagerbestand von: " + p3.getName() + " auf \""
- + stock.getStock(p3) + "\" erhöht");
- stock.add(p4, 17);
- System.out.println(c + "Lagerbestand von: " + p4.getName() + " auf \""
- + stock.getStock(p4) + "\" erhöht");
- stock.add(p5, 22);
- System.out.println(c + "Lagerbestand von: " + p5.getName() + " auf \""
- + stock.getStock(p5) + "\" erhöht");
- stock.add(p6, 8);
- System.out.println(c + "Lagerbestand von: " + p6.getName() + " auf \""
- + stock.getStock(p6) + "\" erhöht");
- stock.add(p7, 13);
- System.out.println(c + "Lagerbestand von: " + p7.getName() + " auf \""
- + stock.getStock(p7) + "\" erhöht");
- stock.add(p8, 4);
- System.out.println(c + "Lagerbestand von: " + p8.getName() + " auf \""
- + stock.getStock(p8) + "\" erhöht");
- stock.add(p9, 11);
- System.out.println(c + "Lagerbestand von: " + p9.getName() + " auf \""
- + stock.getStock(p9) + "\" erhöht");
- stock.add(p10, 7);
- System.out.println(c + "Lagerbestand von: " + p10.getName() + " auf \""
- + stock.getStock(p10) + "\" erhöht");
- stock.add(p11, 12);
- System.out.println(c + "Lagerbestand von: " + p11.getName() + " auf \""
- + stock.getStock(p11) + "\" erhöht");
- stock.add(p12, 25);
- System.out.println(c + "Lagerbestand von: " + p12.getName() + " auf \""
- + stock.getStock(p12) + "\" erhöht");
- stock.add(p13, 34);
- System.out.println(c + "Lagerbestand von: " + p13.getName() + " auf \""
- + stock.getStock(p13) + "\" erhöht");
- stock.add(p14, 7);
- System.out.println(c + "Lagerbestand von: " + p14.getName() + " auf \""
- + stock.getStock(p14) + "\" erhöht");
- stock.add(p15, 9);
- System.out.println(c + "Lagerbestand von: " + p15.getName() + " auf \""
- + stock.getStock(p15) + "\" erhöht");
- stock.add(p16, 22);
- System.out.println(c + "Lagerbestand von: " + p16.getName() + " auf \""
- + stock.getStock(p16) + "\" erhöht");
- stock.add(p17, 23);
- System.out.println(c + "Lagerbestand von: " + p17.getName() + " auf \""
- + stock.getStock(p17) + "\" erhöht");
- stock.add(p18, 39);
- System.out.println(c + "Lagerbestand von: " + p18.getName() + " auf \""
- + stock.getStock(p18) + "\" erhöht");
- stock.add(p19, 21);
- System.out.println(c + "Lagerbestand von: " + p19.getName() + " auf \""
- + stock.getStock(p19) + "\" erhöht");
- stock.add(p20, 6);
- System.out.println(c + "Lagerbestand von: " + p20.getName() + " auf \""
- + stock.getStock(p20) + "\" erhöht");
- stock.add(p21, 11);
- System.out.println(c + "Lagerbestand von: " + p21.getName() + " auf \""
- + stock.getStock(p21) + "\" erhöht\n");
- System.out.println(c + taskB1);
- stock.take(p1, 2);
- System.out
- .println(c + "Lagerbestand von: " + p1.getName()
- + " wurde auf \"" + stock.getStock(p1)
- + "\" verringert");
- stock.take(p7, 7);
- System.out
- .println(c + "Lagerbestand von: " + p7.getName()
- + " wurde auf \"" + stock.getStock(p7)
- + "\" verringert");
- stock.take(p13, 21);
- System.out.println(c + "Lagerbestand von: " + p13.getName()
- + " wurde auf \"" + stock.getStock(p13)
- + "\" verringert\n");
- System.out.println(c + taskC);
- // Create the product-groups and add the corresponding products
- ProductGroup g1 = new ProductGroup("Internal Optical Drives");
- g1.add(p1);
- g1.add(p21);
- System.out.println(c + "Produktgruppe \"" + g1.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- Iterator<Product> it = g1.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g2 = new ProductGroup("Internal Magnetic Drives");
- g2.add(p2);
- System.out.println(c + "Produktgruppe \"" + g2.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g2.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -internal Drives
- ProductGroup g3 = new ProductGroup("Internal Drives");
- g3.add(g1);
- g3.add(g2);
- System.out.println(c + "Produktgruppe \"" + g3.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g3.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -case-products
- ProductGroup g4 = new ProductGroup("Cases");
- g4.add(p3);
- g4.add(p4);
- System.out.println(c + "Produktgruppe \"" + g4.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g4.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g5 = new ProductGroup("AMD");
- g5.add(p5);
- System.out.println(c + "Produktgruppe \"" + g5.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g5.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g6 = new ProductGroup("INTEL");
- g6.add(p6);
- System.out.println(c + "Produktgruppe \"" + g6.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g6.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -processors
- ProductGroup g7 = new ProductGroup("CPU");
- g7.add(g5);
- g7.add(g6);
- System.out.println(c + "Produktgruppe \"" + g7.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g7.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -hddÔøΩs
- ProductGroup g8 = new ProductGroup("HDD");
- g8.add(p7);
- g8.add(p8);
- System.out.println(c + "Produktgruppe \"" + g8.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g8.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -mainboards
- ProductGroup g9 = new ProductGroup("Mainboards");
- g9.add(p9);
- g9.add(p10);
- System.out.println(c + "Produktgruppe \"" + g9.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g9.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g10 = new ProductGroup("DDR3");
- g10.add(p11);
- System.out.println(c + "Produktgruppe \"" + g10.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g10.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g11 = new ProductGroup("DDR2");
- g11.add(p12);
- System.out.println(c + "Produktgruppe \"" + g11.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g11.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -RAM
- ProductGroup g12 = new ProductGroup("Memory");
- g12.add(g10);
- g12.add(g11);
- System.out.println(c + "Produktgruppe \"" + g12.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g12.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -gfxCard
- ProductGroup g13 = new ProductGroup("Graficscard");
- g13.add(p13);
- g13.add(p14);
- System.out.println(c + "Produktgruppe \"" + g13.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g13.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -cooling
- ProductGroup g14 = new ProductGroup("Cooling");
- g14.add(p15);
- g14.add(p16);
- System.out.println(c + "Produktgruppe \"" + g14.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g14.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -acSupply
- ProductGroup g15 = new ProductGroup("Power Supply");
- g15.add(p17);
- g15.add(p18);
- System.out.println(c + "Produktgruppe \"" + g15.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g15.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g16 = new ProductGroup("100 MBit");
- g16.add(p19);
- System.out.println(c + "Produktgruppe \"" + g16.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g16.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- ProductGroup g17 = new ProductGroup("1000 MBit");
- g17.add(p20);
- System.out.println(c + "Produktgruppe \"" + g17.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g17.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- // -networking
- ProductGroup g18 = new ProductGroup("Networking");
- g18.add(g16);
- g18.add(g17);
- System.out.println(c + "Produktgruppe \"" + g18.getName()
- + "\" wurde erstellt und enthält folgende Produkte:");
- it = g18.getProducts().iterator();
- while (it.hasNext()) {
- Product p = it.next();
- System.out.println(c + "\t" + p.getName() + " (Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- } catch (StockException e1) {
- }
- System.out.println(c + taskF);
- Configuration c1 = new Configuration("Business Desktop PC, small", 999.00, 9.00);
- c1.add(p21, 1);
- c1.add(p2, 1);
- c1.add(p3, 1);
- c1.add(p5, 1);
- c1.add(p7, 2);
- c1.add(p9, 1);
- c1.add(p1, 2);
- c1.add(p13, 2);
- c1.add(p15, 1);
- c1.add(p18, 1);
- c1.add(p20, 2);
- stock.add(c1);
- System.out.println(c + "Konfiguration: " + c1.getName()
- + " wurde erstellt und enthält folgende Produkte:");
- HashMap<Product, Integer> productMap = c1.getConfiguration();
- for (Product p : productMap.keySet()) {
- System.out.println(c + "\t" + p.getName() + " ("
- + productMap.get(p) + " Stk.; Lagerbestand: "
- + stock.getStock(p) + ")");
- }
- System.out.print("\n");
- System.out.println(c + taskG);
- System.out.println(c + "\"" + stock.getStock(c1)
- + "\"" + " " + "\"" + c1.getName() + "\""
- + " können erstellt werden.\n");
- System.out.println(c + taskH);
- System.out.println(c + "Entferne Konfiguration \"" + c1.getName()
- + "\" 2x");
- try {
- stock.take(c1, 2);
- } catch (StockException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (Product p : productMap.keySet()){
- System.out.println(c + "\tLagerbestand von " + p.getName()
- + " beträgt " + stock.getStock(p));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement