diff --git a/Exam1_24th Sept/readme.docx b/Exam1_24th Sept/readme.docx new file mode 100644 index 00000000..ec53df02 Binary files /dev/null and b/Exam1_24th Sept/readme.docx differ diff --git a/Exam1_24th Sept/src/com/demo/bean/Apparel.java b/Exam1_24th Sept/src/com/demo/bean/Apparel.java new file mode 100644 index 00000000..23c51aba --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/bean/Apparel.java @@ -0,0 +1,50 @@ +package com.demo.bean; + +//Inherits Items Class +public class Apparel extends Items { + private int size; + private String material; + + + //Default Constructor + public Apparel() { + this.size = 0; + this.material = null; + } + + //Parameterized Constructor + public Apparel(int code, String name, float price, int qty, int size, String material) { + super(code, name, price, qty); + this.size = size; + this.material = material; + } + + + + //Getter and Setter Methods + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + + //ToString method overridden + + @Override + public String toString() { + return "Apparel{" + + "size=" + size + + ", material='" + material + '\'' + + '}'; + } +} diff --git a/Exam1_24th Sept/src/com/demo/bean/Electronics.java b/Exam1_24th Sept/src/com/demo/bean/Electronics.java new file mode 100644 index 00000000..3f5f2836 --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/bean/Electronics.java @@ -0,0 +1,39 @@ +package com.demo.bean; + + +//Inherited Items class +public class Electronics extends Items{ + private int wrntyMnths; + + + //Default Constructor + public Electronics() { + wrntyMnths=0; + } + + + //Parameterized Constructor + public Electronics(int code, String name, float price,int qty) { + super(code, name, price, qty); + wrntyMnths=0; + } + + + //Setter & Getter Methods + public int getWrntyMnths() { + return wrntyMnths; + } + + public void setWrntyMnths(int wrntyMnths) { + this.wrntyMnths = wrntyMnths; + } + + + //ToString method to override + @Override + public String toString() { + return "Electronics{" + + "wrntyMnths=" + wrntyMnths + + '}'; + } +} diff --git a/Exam1_24th Sept/src/com/demo/bean/FoodItems.java b/Exam1_24th Sept/src/com/demo/bean/FoodItems.java new file mode 100644 index 00000000..71d0036d --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/bean/FoodItems.java @@ -0,0 +1,67 @@ +package com.demo.bean; + +import java.text.SimpleDateFormat; +import java.util.Date; + +//FoodItems class has inherited the Items class +public class FoodItems extends Items{ + + private Date dOfManf; + private Date dOfExp; + //1 for vegeteraian, 0 for non-vegeterian + private int vegType; + + + //Default Constructor + public FoodItems() { + this.dOfManf = null; + this.dOfExp = null; + this.vegType = 0; + } + + + //Parameterized Constructor + public FoodItems(int code, String name, float price, int qty, Date dOfManf, Date dOfExp, int vegType) { + super(code, name, price, qty); + this.dOfManf = dOfManf; + this.dOfExp = dOfExp; + this.vegType = vegType; + } + + //Setter and Getter Methods + public Date getdOfManf() { + return dOfManf; + } + + public void setdOfManf(Date dOfManf) { + this.dOfManf = dOfManf; + } + + public Date getdOfExp() { + return dOfExp; + } + + public void setdOfExp(Date dOfExp) { + this.dOfExp = dOfExp; + } + + public int getVegType() { + return vegType; + } + + public void setVegType(int vegType) { + this.vegType = vegType; + } + +// //ToString method overridden + @Override + public String toString() { + return "FoodItems{" + + "dOfManf=" + dOfManf + + ", dOfExp=" + dOfExp + + ", vegType=" + vegType + + '}'; + } + + +} diff --git a/Exam1_24th Sept/src/com/demo/bean/Items.java b/Exam1_24th Sept/src/com/demo/bean/Items.java new file mode 100644 index 00000000..9559a858 --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/bean/Items.java @@ -0,0 +1,77 @@ +package com.demo.bean; + +//POJO class for all the 3 items +public class Items { + protected int code; + protected String name; + protected float price; + protected int qty; + + +//static int count=0; + + //Default Constructor + public Items() { + code=1110; + name=null; + price=0.0f; + qty=0; + } + + //Parameterized Constructor + public Items(int code, String name, float price,int qty) { + //count++; + this.code = code; + this.name = name; + this.price = price; + this.qty=qty; + } + + + + //Setter and Getter Methods + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getPrice() { + return price; + } + + public void setPrice(float price) { + this.price = price; + } + + public int getQty() { + return qty; + } + + public void setQty(int qty) { + this.qty = qty; + } + + + + //ToString method overridden to be shown in System.out.println() + @Override + public String toString() { + return "Items{" + + "code=" + code + + ", name='" + name + '\'' + + ", price=" + price + + ", qty=" + qty + + '}'; + } +} diff --git a/Exam1_24th Sept/src/com/demo/dao/ItemDao.java b/Exam1_24th Sept/src/com/demo/dao/ItemDao.java new file mode 100644 index 00000000..67fb0e49 --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/dao/ItemDao.java @@ -0,0 +1,7 @@ +package com.demo.dao; + +public interface ItemDao { + + + +} diff --git a/Exam1_24th Sept/src/com/demo/dao/ItemDaoImpl.java b/Exam1_24th Sept/src/com/demo/dao/ItemDaoImpl.java new file mode 100644 index 00000000..541259bc --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/dao/ItemDaoImpl.java @@ -0,0 +1,56 @@ +package com.demo.dao; + +import com.demo.bean.Items; +import com.demo.bean.FoodItems; +import com.demo.bean.Apparel; +import com.demo.bean.Electronics; +import com.demo.exception.ItemNotFoundException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ItemDaoImpl implements ItemDao{ + + public List ilist; + + //Compares 2 products based on quantity + + public int compare(Items i1,Items i2) throws ItemNotFoundException{ + + return 0; + + } + + /*//To compare + + public List getItems(List list){ + ArrayList ls=new ArrayList<>(); + //Collections.sort(list, new ); + + }*/ + + + //Adds 2 products + public void addItem(Items iarr) { + ilist.add(iarr); + } + + //Display items + public List getProducts(List list) { + // TODO Auto-generated method stub + ArrayList newList= new ArrayList<>(); + //Collections.sort(list, new ()); + for(int i=0;i<3;i++) + { + newList.add((Items) list.get(i)); + } + return newList; + } +//To display all the items + public List getAllItemss() { + // TODO Auto-generated method stub + return this.ilist; + } + +} diff --git a/Exam1_24th Sept/src/com/demo/exception/ItemNotFoundException.java b/Exam1_24th Sept/src/com/demo/exception/ItemNotFoundException.java new file mode 100644 index 00000000..58274a8d --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/exception/ItemNotFoundException.java @@ -0,0 +1,8 @@ +package com.demo.exception; + +//If the item asked by the user is not found +public class ItemNotFoundException extends Exception { + public ItemNotFoundException(String msg) { + super(msg); + } +} diff --git a/Exam1_24th Sept/src/com/demo/service/ItemService.java b/Exam1_24th Sept/src/com/demo/service/ItemService.java new file mode 100644 index 00000000..422ab90a --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/service/ItemService.java @@ -0,0 +1,33 @@ +package com.demo.service; + +import com.demo.exception.ItemNotFoundException; +import com.demo.bean.Items; +import com.demo.bean.Electronics; +import com.demo.bean.FoodItems; +import com.demo.bean.Apparel; +import com.demo.dao.ItemDaoImpl; +import com.demo.dao.ItemDao; + +import java.util.Scanner; + + +//Service Class to interact with dao and test layers +public class ItemService { + + static { + sc=new Scanner(System.in); + } + static Scanner sc; + private ItemDao itemDao; + + + //Method to add items + public void addItem(Items iarr) { + + } + + public void displayAll(Items iarr){ + + } + +} diff --git a/Exam1_24th Sept/src/com/demo/test/TestItems.java b/Exam1_24th Sept/src/com/demo/test/TestItems.java new file mode 100644 index 00000000..bdef6a67 --- /dev/null +++ b/Exam1_24th Sept/src/com/demo/test/TestItems.java @@ -0,0 +1,18 @@ +package com.demo.test; +import com.demo.bean.Items; +import com.demo.dao.ItemDaoImpl; +import com.demo.dao.ItemDao; +import com.demo.service.ItemService; +import java.util.ArrayList; + +//Main Class to test + +public class TestItems { + + public static void main(String[] args) { + ItemService itemService=new ItemService(); + ArrayList items=new ArrayList<>(); + + + } +}