diff --git a/Assignment1/.classpath b/Assignment1/.classpath new file mode 100644 index 00000000..51a8bbad --- /dev/null +++ b/Assignment1/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Assignment1/.project b/Assignment1/.project new file mode 100644 index 00000000..a1f9df84 --- /dev/null +++ b/Assignment1/.project @@ -0,0 +1,17 @@ + + + Assignment1 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Assignment1/.settings/org.eclipse.jdt.core.prefs b/Assignment1/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..ec1937b3 --- /dev/null +++ b/Assignment1/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Assignment1/bin/com/demo/bean/Account.class b/Assignment1/bin/com/demo/bean/Account.class new file mode 100644 index 00000000..6f897941 Binary files /dev/null and b/Assignment1/bin/com/demo/bean/Account.class differ diff --git a/Assignment1/bin/com/demo/service/AccountService.class b/Assignment1/bin/com/demo/service/AccountService.class new file mode 100644 index 00000000..16854635 Binary files /dev/null and b/Assignment1/bin/com/demo/service/AccountService.class differ diff --git a/Assignment1/bin/com/demo/test/TestAccountClass.class b/Assignment1/bin/com/demo/test/TestAccountClass.class new file mode 100644 index 00000000..fb570b56 Binary files /dev/null and b/Assignment1/bin/com/demo/test/TestAccountClass.class differ diff --git a/Assignment1/src/com/demo/bean/Account.java b/Assignment1/src/com/demo/bean/Account.java new file mode 100644 index 00000000..0be4ba9d --- /dev/null +++ b/Assignment1/src/com/demo/bean/Account.java @@ -0,0 +1,72 @@ +package com.demo.bean; +import java.util.Date; + +public class Account { + static { + cnt = 0; + } + + private static int cnt; + private int perId; + private String pName; + private String typeOfAcc; + private Date dOp; + private double balance; + + //default constructor + public Account() { + perId = 0; + pName = null; + typeOfAcc = null; + dOp = null; + + } + + //parameterized constructor + public Account(String pName, String typeOfAcc, Date dOp, double bal) { + this.perId = cnt++ ; + this.pName = pName; + this.typeOfAcc = typeOfAcc; + this.dOp = dOp; + this.balance = bal; + } + //setter and getter methods + public int getId() { + return this.perId; + } + public void setId(int perId) { + this.perId = perId; + } + public void setBal (double bal) { + this.balance = bal; + } + public double getBal() { + return this.balance; + } + public String getpName() { + return this.pName; + } + public void setpName(String pName) { + this.pName = pName; + } + + //Deposit function + public void deposit(double amt) { + balance = balance + amt; + } + + //Withdraw function + public void withdraw(double amt) { + if(balance-10000 >= amt) { + balance = balance - amt; + } + else { + System.out.println("Insufficient Balance"); + } + } + + @Override + public String toString() { + return "Id: "+perId +"\nName: " +pName + "\nType of account:"+ typeOfAcc + "\nDate of opening :"+ dOp+"\nbalance: "+balance; + } +} diff --git a/Assignment1/src/com/demo/service/AccountService.java b/Assignment1/src/com/demo/service/AccountService.java new file mode 100644 index 00000000..ea165c23 --- /dev/null +++ b/Assignment1/src/com/demo/service/AccountService.java @@ -0,0 +1,96 @@ +package com.demo.service; + +import java.util.Scanner; +import com.demo.bean.Account; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class AccountService { + public static Scanner sc = new Scanner(System.in); + + // Accept Account Method + public static void acceptAccountData(Account[] acc) { + for (int i = 0; i < acc.length; i++) { + System.out.println("Enter account holder's name: "); + String name = sc.next(); + System.out.println("Enter type of account: "); + String acctype = sc.next(); + System.out.println("Enter balance: "); + double bal = sc.nextDouble(); + Date dOp = new Date(); + acc[i] = new Account(name, acctype, dOp, bal); + } + + } + + //Search by ID Method + public static int searchById(Account[] acc, int id) { + for (int i = 0; i < acc.length; i++) { + if (acc[i].getId() == id) { + return i; + } + } + return -1; + } + + //Deposit Amount method + public static int depositAmt(Account[] acc, int id, double amt) { + int pos = searchById(acc, id); + if (pos != -1) { + pos=pos+1; + acc[pos].deposit(amt); + System.out.println("New balance:" + acc[pos].getBal()); + return pos; + } else { + System.out.println("person not found"); + return -1; + } + } + + //Withdraw Method + public static int withdrawAmt(Account[] acc, int id, double amt) { + + int pos = searchById(acc, id); + if (pos != -1) { + acc[pos].withdraw(amt); + System.out.println("New balance:" + acc[pos].getBal()); + return pos; + } else { + System.out.println("person not found"); + return -1; + } + + } + + //Display Data + public static void displayData(Account[] acc) { + for (int i = 0; i < acc.length; i++) { + if (acc[i] != null) { + System.out.println(acc[i]); + } else { + break; + } + } + } + + //Search by Name + public static int searchByName(Account[] a, String nm) { + for (int i = 0; i < a.length; i++) { + if (a[i].getpName().equals(nm)) { + return i; + } + } + return -1; + } + + // Show Data by ID + public static void dispById(Account[] a, int id) { + int pos = searchById(a, id); + if (pos != -1) { + System.out.println(a[pos]); + } else { + System.out.println("Account not found"); + } + } +} diff --git a/Assignment1/src/com/demo/test/TestAccountClass.java b/Assignment1/src/com/demo/test/TestAccountClass.java new file mode 100644 index 00000000..2d1afd37 --- /dev/null +++ b/Assignment1/src/com/demo/test/TestAccountClass.java @@ -0,0 +1,63 @@ +package com.demo.test; + +import com.demo.bean.Account; +import com.demo.service.AccountService; +import java.util.Scanner; + +public class TestAccountClass { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + Account[] a = new Account[3]; + int choice = 0; + + //Main Menu with options + do { + System.out.println("1. New Account : \n2. Search Account by ID : \n3. Deposit : \n4. Withdraw : \n5. Search Account by Name : \n6. Exit"); + choice = sc.nextInt(); + switch (choice) { + case 1: + AccountService.acceptAccountData(a); + break; + case 2: + System.out.println("Enter ID name "); + int id = sc.nextInt(); + int pos = AccountService.searchById(a, id); + if (pos != -1) { + System.out.println(a[pos]); + } else { + System.out.println("No such ID found"); + } + break; + case 3: + System.out.println("Deposit Amount : "); + double damt = sc.nextDouble(); + System.out.println("Enter the Account ID: "); + int dId = sc.nextInt(); + AccountService.depositAmt(a, dId, damt); + break; + case 4: + System.out.println("Withdraw Amount: "); + double wAmt = sc.nextDouble(); + System.out.println("Enter the Account ID: "); + int wId = sc.nextInt(); + AccountService.withdrawAmt(a, wId, wAmt); + break; + case 5: + System.out.println("Enter Name"); + String nm = sc.next(); + int posn = AccountService.searchByName(a, nm); + if (posn != -1) { + System.out.println(a[posn]); + } else { + System.out.println("Person Not Found"); + } + break; + case 6: + System.exit(0); + } + } while (choice != 6); + sc.close(); + } + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/.classpath b/Practical_Exam_Shubham_Tapele_WPS4/.classpath new file mode 100644 index 00000000..51a8bbad --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Practical_Exam_Shubham_Tapele_WPS4/.project b/Practical_Exam_Shubham_Tapele_WPS4/.project new file mode 100644 index 00000000..f6e028ed --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/.project @@ -0,0 +1,17 @@ + + + PracticalExam + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Practical_Exam_Shubham_Tapele_WPS4/.settings/org.eclipse.jdt.core.prefs b/Practical_Exam_Shubham_Tapele_WPS4/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..ec1937b3 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Apparel.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Apparel.class new file mode 100644 index 00000000..3f8270c9 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Apparel.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Electronics.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Electronics.class new file mode 100644 index 00000000..34fdaf64 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Electronics.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Food.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Food.class new file mode 100644 index 00000000..7856848d Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Food.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Item.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Item.class new file mode 100644 index 00000000..99ba01a2 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/bean/Item.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDao.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDao.class new file mode 100644 index 00000000..7ddf8e54 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDao.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDaoImpl.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDaoImpl.class new file mode 100644 index 00000000..ec48ae31 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/dao/ItemDaoImpl.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/exception/ItemNotFoundException.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/exception/ItemNotFoundException.class new file mode 100644 index 00000000..0817eac7 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/exception/ItemNotFoundException.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemService.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemService.class new file mode 100644 index 00000000..84f04514 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemService.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemServiceImpl.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemServiceImpl.class new file mode 100644 index 00000000..466637d2 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/service/ItemServiceImpl.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/test/TestItemSet.class b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/test/TestItemSet.class new file mode 100644 index 00000000..3aaa5b63 Binary files /dev/null and b/Practical_Exam_Shubham_Tapele_WPS4/bin/com/demo/test/TestItemSet.class differ diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Apparel.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Apparel.java new file mode 100644 index 00000000..9cf1fd96 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Apparel.java @@ -0,0 +1,64 @@ +//Shubham Ramesh Tapele +//Apparel Class which extends Item Class and Stores Apparel Specific Variables + +package com.demo.bean; + +public class Apparel extends Item{ + private String size; + private String material; + private int qnty; + + //default constructor + public Apparel() { + super(); + } + + //parameterised Constructor + public Apparel(String size, String material, int qnty, int itemCode, String itemName, double price) { + super(); + this.size = size; + this.material = material; + this.qnty = qnty; + } + + //Getter and Setter Methods + public String getSize() { + return size; + } + public void setSize(String size) { + this.size = size; + } + public String getMaterial() { + return material; + } + public void setMaterial(String material) { + this.material = material; + } + public int getQnty() { + return qnty; + } + public void setQnty(int qnty) { + this.qnty = qnty; + } + + + @Override + public String toString() { + return "Apparel [size=" + size + ", material=" + material + ", qnty=" + qnty + "]"; + } + //compare function to sort by qnty + public int compareTo(Apparel ob) { + System.out.println("In person compareTo"+qnty+"----"+ob.qnty); + if(this.qnty>ob.qnty) { + return -1; + }else if(this.qnty==ob.qnty) { + return 0; + } + else { + return 1; + } + } + + + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Electronics.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Electronics.java new file mode 100644 index 00000000..98721a10 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Electronics.java @@ -0,0 +1,60 @@ +//Shubham Ramesh Tapele +//Electronics Class which extends Item Class and Stores Electronics Specific Variables + +package com.demo.bean; + +public class Electronics extends Item{ + private int warranty; + private int qnty; + + + //default Constructor + public Electronics() { + super(); + } + + //parameterised Constructor + public Electronics(int warranty, int qnty, int itemCode, String itemName, double price) { + super(); + this.warranty = warranty; + this.qnty = qnty; + } + + + + + + //Getter and Seter Methods + public int getWarranty() { + return warranty; + } + + public void setWarranty(int warranty) { + this.warranty = warranty; + } + public int getQnty() { + return qnty; + } + + + public void setQnty(int qnty) { + this.qnty = qnty; + } + @Override + public String toString() { + return "Electronics [warranty=" + warranty + ", qnty=" + qnty + "]"; + } + //compare function to sort by qnty + public int compareTo(Electronics ob) { + System.out.println("In person compareTo"+qnty+"----"+ob.qnty); + if(this.qnty>ob.qnty) { + return -1; + }else if(this.qnty==ob.qnty) { + return 0; + } + else { + return 1; + } + } + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Food.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Food.java new file mode 100644 index 00000000..d08d7172 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Food.java @@ -0,0 +1,85 @@ +//Shubham Ramesh Tapele +//Food Class which extends Item Class and Stores Food Specific Variables + +package com.demo.bean; + +import java.util.Date; + +public class Food extends Item{ + private String manu; + private String exp; + private String type; + private int qnty; + + //default constructor + public Food() { + super(); + } + + + //parameterised constructor + public Food(String string, String string2, String type, int qnty, int itemCode, String itemName, double price) { + super(); + this.manu = string; + this.exp = string2; + this.type = type; + this.qnty = qnty; + } + + + //Getter and Setter Methods + + + public String getManu() { + return manu; + } + public void setManu(String manu) { + this.manu = manu; + } + public String getExp() { + return exp; + } + public void setExp(String exp) { + this.exp = exp; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + public int getQnty() { + return qnty; + } + + + public void setQnty(int qnty) { + this.qnty = qnty; + } + + + //toString Method + @Override + public String toString() { + return "Food [manu=" + manu + ", exp=" + exp + ", type=" + type + ", qnty=" + qnty + "]"; + } + //compare function to sort by qnty + public int compareTo(Food ob) { + System.out.println("In person compareTo"+qnty+"----"+ob.qnty); + if(this.qnty>ob.qnty) { + return -1; + }else if(this.qnty==ob.qnty) { + return 0; + } + else { + return 1; + } + } + + + + + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Item.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Item.java new file mode 100644 index 00000000..cda95b80 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/bean/Item.java @@ -0,0 +1,53 @@ +//Shubham Ramesh Tapele +//Item Class(Parent Class) + +package com.demo.bean; + +public class Item { + private int itemCode; + private String itemName; + private double price; + + //default constructor + public Item() { + super(); + } + + //parameterised constructor + public Item(int itemCode, String itemName, double price) { + super(); + this.itemCode = itemCode; + this.itemName = itemName; + this.price = price; + } + + + //Getter and Setter methods of all the variables + public int getItemCode() { + return itemCode; + } + public void setItemCode(int itemCode) { + this.itemCode = itemCode; + } + public String getItemName() { + return itemName; + } + public void setItemName(String itemName) { + this.itemName = itemName; + } + public double getPrice() { + return price; + } + public void setPrice(double price) { + this.price = price; + } + + + //toString method + @Override + public String toString() { + return "Item [itemCode=" + itemCode + ", itemName=" + itemName + ", price=" + price + "]"; + } + + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDao.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDao.java new file mode 100644 index 00000000..ccca724b --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDao.java @@ -0,0 +1,21 @@ +//Shubham Ramesh Tapele +//Dao Layer Interface + +package com.demo.dao; + +import java.util.Set; + +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.bean.Food; + +public interface ItemDao { + + + Set getAllElec(); + + Set getAllApp(); + + Set getAllFood(); + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDaoImpl.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDaoImpl.java new file mode 100644 index 00000000..f946155f --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/dao/ItemDaoImpl.java @@ -0,0 +1,39 @@ +//Shubham Ramesh Tapele +//Dao Layer Implementaion of Dao Interface + +package com.demo.dao; + +import java.util.Set; +import java.util.TreeSet; + +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.bean.Food; + +public class ItemDaoImpl implements ItemDao{ + //Create Set of all Entities + static Set eset; + static Set aset; + static Set fset; + static { + eset=new TreeSet<>(); + aset=new TreeSet<>(); + fset=new TreeSet<>(); + } + //Function to get all Electronics + @Override + public Set getAllElec() { + return eset; + } + //Function to get all Apparel + @Override + public Set getAllApp() { + return aset; + } + //Function to get all Food + @Override + public Set getAllFood() { + return fset; + } + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/exception/ItemNotFoundException.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/exception/ItemNotFoundException.java new file mode 100644 index 00000000..3dc0fce4 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/exception/ItemNotFoundException.java @@ -0,0 +1,5 @@ +package com.demo.exception; + +public class ItemNotFoundException extends Exception{ + System.out.println("Item not found"); +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemService.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemService.java new file mode 100644 index 00000000..b2a63b41 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemService.java @@ -0,0 +1,29 @@ +//Shubham Ramesh Tapele +//Interface to have all ServiceLAyer Functions Initialiser + +package com.demo.service; + +import java.util.Set; + +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.bean.Food; + +public interface ItemService { + + static Set getAllFood() { + // TODO Auto-generated method stub + return null; + } + Set getAllElec(); + Set getAllApp(); + static Set getAllApparel() { + // TODO Auto-generated method stub + return null; + } + static Set getAllElectronics() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemServiceImpl.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemServiceImpl.java new file mode 100644 index 00000000..1067cebc --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/service/ItemServiceImpl.java @@ -0,0 +1,42 @@ +//Shubham Ramesh Tapele +//Implementaion of Service Interface + +package com.demo.service; + +import java.text.SimpleDateFormat; +import java.util.Scanner; +import java.util.Set; + +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.bean.Food; +import com.demo.dao.ItemDaoImpl; + +public class ItemServiceImpl implements ItemService{ + + private ItemDaoImpl itemDao; + static Scanner sc; + static SimpleDateFormat sdf; + static { + sc=new Scanner(System.in); + sdf=new SimpleDateFormat("dd/MM/yyyy"); + + } + + + //Funtion to call Dao layer + public Set getAllFood() { + return itemDao.getAllFood(); + } + //Funtion to call Dao layer + @Override + public Set getAllElec() { + return itemDao.getAllElec(); + } + //Funtion to call Dao layer + @Override + public Set getAllApp() { + return itemDao.getAllApp(); + } + +} diff --git a/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/test/TestItemSet.java b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/test/TestItemSet.java new file mode 100644 index 00000000..a1831e60 --- /dev/null +++ b/Practical_Exam_Shubham_Tapele_WPS4/src/com/demo/test/TestItemSet.java @@ -0,0 +1,74 @@ +package com.demo.test; + +import java.util.Scanner; +import java.util.Set; +import com.demo.exception.*; +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.bean.Food; +import com.demo.service.ItemService; + + +public class TestItemSet { + + public static void main(String[] args) { + int choice=0; + Scanner sc=new Scanner(System.in); + + + //Parameter Creation of Food Objects + Food f1=new Food("20/10/2010", "22/10/2010", "Veg", 10, 1, "Bread", 1); + Food f2=new Food("20/9/2010", "22/9/2010", "Veg", 20, 2, "Juice", 2); + Food f3=new Food("20/8/2010", "22/8/2010", "Veg", 30, 3, "Colddrink", 3); + Food f4=new Food("20/7/2010", "22/7/2010", "Veg", 40, 4, "Bun", 4); + + + //Parameter Creation of Apparel Objects + Apparel a1=new Apparel("Medium", "Cotton", 10, 1, "Dress", 10); + Apparel a2=new Apparel("Medium", "Cotton", 20, 2, "Pant", 20); + Apparel a3=new Apparel("Medium", "Cotton", 30, 3, "Shirt", 30); + Apparel a4=new Apparel("Medium", "Cotton", 40, 4, "Tshirt", 40); + + //Parameter Creation of Electronics Objects + Electronics e1=new Electronics(10, 10, 1, "Radio", 10); + Electronics e2=new Electronics(20, 20, 2, "TV", 20); + Electronics e3=new Electronics(30, 30, 3, "Ipod", 30); + Electronics e4=new Electronics(40, 40, 4, "Mobile", 40); + + //Do while Loop to Carry on till exit is called + do { + System.out.println("1. Food Set Report"); + System.out.println("2. Apparel Report"); + System.out.println("3. Electronics Report"); + System.out.println("4. Exit"); + System.out.println("choice: "); + choice=sc.nextInt(); + //switchcase for all option + switch(choice) { + case 1: + Set foodSet=ItemService.getAllFood(); + for(Food food:foodSet) { + System.out.println(food); + break;} + case 2: + Set appSet=ItemService.getAllApparel(); + for(Apparel app:appSet) { + System.out.println(app); + } + break; + case 3: + Set elecSet=ItemService.getAllElectronics(); + for(Electronics elec:elecSet) { + System.out.println(elec); + } + break; + + case 4: + sc.close(); + System.exit(0); + break; + } + }while(choice!=4); + + } +}