Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24th test shirshendhu #29

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Exam1_24th Sept/readme.docx
Binary file not shown.
50 changes: 50 additions & 0 deletions Exam1_24th Sept/src/com/demo/bean/Apparel.java
Original file line number Diff line number Diff line change
@@ -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 + '\'' +
'}';
}
}
39 changes: 39 additions & 0 deletions Exam1_24th Sept/src/com/demo/bean/Electronics.java
Original file line number Diff line number Diff line change
@@ -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 +
'}';
}
}
67 changes: 67 additions & 0 deletions Exam1_24th Sept/src/com/demo/bean/FoodItems.java
Original file line number Diff line number Diff line change
@@ -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 +
'}';
}


}
77 changes: 77 additions & 0 deletions Exam1_24th Sept/src/com/demo/bean/Items.java
Original file line number Diff line number Diff line change
@@ -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 +
'}';
}
}
7 changes: 7 additions & 0 deletions Exam1_24th Sept/src/com/demo/dao/ItemDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.demo.dao;

public interface ItemDao {



}
56 changes: 56 additions & 0 deletions Exam1_24th Sept/src/com/demo/dao/ItemDaoImpl.java
Original file line number Diff line number Diff line change
@@ -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<Items> ilist;

//Compares 2 products based on quantity

public int compare(Items i1,Items i2) throws ItemNotFoundException{

return 0;

}

/*//To compare

public List<Items> getItems(List list){
ArrayList<Items> ls=new ArrayList<>();
//Collections.sort(list, new );

}*/


//Adds 2 products
public void addItem(Items iarr) {
ilist.add(iarr);
}

//Display items
public List<Items> getProducts(List list) {
// TODO Auto-generated method stub
ArrayList<Items> 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<Items> getAllItemss() {
// TODO Auto-generated method stub
return this.ilist;
}

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
33 changes: 33 additions & 0 deletions Exam1_24th Sept/src/com/demo/service/ItemService.java
Original file line number Diff line number Diff line change
@@ -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){

}

}
18 changes: 18 additions & 0 deletions Exam1_24th Sept/src/com/demo/test/TestItems.java
Original file line number Diff line number Diff line change
@@ -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> items=new ArrayList<>();


}
}