Uploaded by nOob vs prO

GROCERY MANAGEMENT SYSTEM

advertisement
ASSIGNMENT-02
Object oriented programming
Submitted by:
SP22-BSE-030
SP22-BSE-027
(H.Mutahar Hashmi)
(M.Ahmad Chaudhary)
“GROCERY MANAGEMENT SYSTEM”
Abstract:
In this Management system we will be able to buy products which belongs to our
grocery might be monthly or daily. In this system we will able to calculate bill of
the apartments wise and then we will able to calculate complete products bills
after it this bill have some tax on per apartment items and then all this creating
whole bill which result in a receipt of bill and total the whole bill.
Idea:
It is our combine decision to make this project and ideas were approaching from
both of us then we write on the page all the ideas and try to lay out the best
possible idea from our mind in this project. For Example: Rainbow cash and carry
and Euro stores having different apartments in it.
Working:
This system will work in the following way:
• First there is a Parent class(Abstract class ) which is Grocery class: In this
class we will have the Abstract method of discount on per item according
to their quantity and weights etc.
• Second as the item in the store having some id and names of every item is
different and now the time of making sub classes of the Grocery which are
actually the apartments when we enter in the Grocery store.
• Food is a Grocery and further Frozen food ,fruits and dairy food is a Food
using the inheritance (IS-A) relation between them
• Then we have another apartment for Pharmacy, House Hold products ,
Cosmetics , Tooth Products.
• Dish soaps is a HouseHold product and also Tooth products is inherited by
the household.
• Now for buying all these products we have a method that is over riding in
all the inherited classes from grocery and are extends towards each other.
Bill Calculation:
Bill in this grocery management system is created by this method:
• First we have a polymorphic methods for the sake of creating the bill
according to the grocery item and we have 5 tax of different apartments
and different products.
• Tax is added according to the product and apartment in the grocery store
bill.
• We have a method which will give us the return amount of the customer
payment and remain of the amount to be paid as change .
• Final polymorphic method in this class is actually which results in all the
amount tax condition that is you have shopped more thean 20000 than you
will charge after some discount .
Some More Ideas:
• We are working on some ideas as well to make this project more efficient
but for now we have all this discussed above.
• We want to add customers and update their data etc in it also but not yet
able to decide but it is in our plans
What will be our Aim ??
Our aim is very simple to create this system efficiently and be able to have a good
working system for the grocery management and also of calculating the bills
according the terms and condition by implying the taxes as well as discounts on
it .
Conclusion:
This system will take data from the user and then it will create bill according to
the terms and conditions of the related apartment in the grocery store and will
able to add and store all the items in the array list in main method and also
polymorphically it will read by the system using instance of and then according
the conditions will be applied on it. At the end Output of the system will be the
products id name quantity and apartment from which it belongs and then the menu
for adding the bill update the bill and deleting the bill and also printing the whole
receipt.
Oop Concepts:
Object oriented programming concepts use in this management system are as
follows:
•
•
•
•
•
Inheritence
Private instance variable
Polymorphism
Method overriding
Abstract classes and methods
•
•
•
•
•
•
•
•
•
Instance of
Type casting
Array list
For each loop
Final variables
Static variables
IS-A relation
Switch cases
Object creation
UML Diagram:
Grocery Class:
package
semesterproject;
public abstract class Grocery {
//attributes
declaration:
private
int
id;
private
String
name;
public
Grocery(int
id,
String
name)
{
this.id
=
id;
this.name
=
name;
}
public
int
getId()
{
return
id;
}
public String getName() {
return
name;
}
public
abstract
double
Discount();
}
Food class:
package
semesterproject;
public
class
Food
Grocery{
private
double
extends
price;
public Food(int id, String
name,
double
price)
{
super(id,
name);
this.price
=
price;
}
public double getPrice() {
return
price;
}
@Override
public double Discount() {
return
0;
}
}
Frozen Food Class:
package
semesterproject;
public class Frozenfood extends
Food{
private
int
quantity;
public
int
getQuantity()
{
return
quantity;
}
public Frozenfood(int id,
String name, double price, int
quantity)
{
super(id, name, price);
this.quantity
=
quantity;
}
@Override
public
double
Discount()
{
if
(quantity
>=3)
{
return
getPrice()*0.10;
}
else
{
return getPrice();
}
}
}
Fruits Class:
package
semesterproject;
public class Fruits extends Food
{
private
double
weight;
public double getWeight()
{
return
weight;
}
public Fruits(int id, String
name,
double
price,
double
weight)
{
super(id, name, price);
this.weight = weight;
}
@Override
public
double
Discount()
{
if
(weight
>=10)
{
return
getPrice()*0.05;
}
else
{
return
}
getPrice();
}
}
House Hold Class:
package
semesterproject;
public class Household extends
Grocery{
private
double
price;
public
Household(int
id,
String name, double price) {
super(id,
name);
this.price
=
price;
}
public double getPrice() {
return
price;
}
@Override
public double Discount() {
return
0;
}
}
Tooth Product Class:
package
semesterproject;
public
class
Toothproducts
extends
Household{
private
int
quantity;
public
Toothproducts(int
id, String name, double price,
int
quantity)
{
super(id, name, price);
this.quantity
=
quantity;
// this.weight = weight;
}
public int getQuantity() {
return
quantity;
}
@Override
public double Discount() {
if
(quantity>2)
{
return
getPrice()*0.10;
}
else{
return getPrice();
}
}
}
Cosmetic Class:
package
semesterproject;
public class Cosmetics extends
Grocery{
//attributes:
private
double
price;
private
int
quantity;
public
Cosmetics(int
id,
String name, double price, int
quantity)
{
super(id,
name);
this.price
=
price;
this.quantity
=
quantity;
}
public double getPrice() {
return
price;
}
public int getQuantity() {
return
quantity;
}
@Override
public double Discount() {
if (quantity >=5) {
return
getPrice()*0.4;
}
else
{
return
getPrice();
}
}
}
Diary Food Class:
package
semesterproject;
public class Diaryfood extends
Food{
private
double
weight;
public
Diaryfood(int
id,
String
name,
double
price,
double
weight)
{
super(id, name, price);
this.weight = weight;
}
public double getWeight() {
return
weight;
}
@Override
public double Discount() {
if
(weight>=5)
{
return
getPrice()*(0.05);
}
else{
return
getPrice();
}
}}
Calculate Bill :
package
semesterproject;
import
java.util.Scanner;
public class Calculatebill {
//we have to create methods
of
add
edit
view;
//add
bill
Scanner
input=new
Scanner(System.in);
Scanner
inputString=new
Scanner(System.in);
Frozenfood
f=new
Frozenfood(12,"Nuggets",1200,2)
;
Fruits
f1=new
Fruits(11,"mewa",1300,2.5);
Household
h=new
Household(14,"sponges",150);
Cosmetics
C=new
Cosmetics(1,"Lipbalm",350,6);
Diaryfood
d=new
Diaryfood(2,"Milk",180,1);
Pharmacy
p=new
Pharmacy(3,"Panadol",3,180);
Toothproducts
t=new
Toothproducts(4,"Colgate",450,3
);
public
void
addBill(Billcalculation
c)
{
c.calculateBill(f);
c.calculateBill(f1);
c.calculateBill(h);
c.calculateBill(C);
c.calculateBill(d);
c.calculateBill(t);
c.calculateBill(p);
}
public
editBill(Billcalculation
{
void
c)
}
public
void
deleteBill(Billcalculation
c)
{
}
public
void
updateBill(Billcalculation
c)
{
}
}
PolyMorphic Class:
package
semesterproject;
public class Billcalculation {
//attributes:
private
double
ammount_paid;
public
Billcalculation(double
ammount_paid)
this.ammount_paid
ammount_paid;
}
{
=
public
double
getAmmount_paid()
{
return
ammount_paid;
}
public static
tax
=
public static
tax1
=
public static
tax2
=
public static
final double
0.7;
final double
0.4;
final double
0.5;
final double
tax3
=
0.8;
public static final double
tax4
=
0.9;
public static final double
tax5
=
0.1;
//creating
method:
public
double
calculateBill(Grocery
g)
{
if (g instanceof Food f)
{
if
(f
instanceof
Frozenfood)
{
return
f.Discount()
+
tax;
}
else
if
(f
instanceof
Fruits)
{
return
f.Discount()
+
tax1;
}
} else if (g instanceof
Household)
{
return g.Discount()
+
tax4;
} else if (g instanceof
Cosmetics)
{
return g.Discount()
+
tax3;
} else if (g instanceof
Pharmacy)
{
return g.Discount()
+
tax2;
} else if (g instanceof
Toothproducts)
{
return g.Discount()
+
tax5;
}
return
g.Discount();
}
public
double
discount_onbill(Grocery
g)
{
if
(calculateBill(g)>=10000)
{
return
calculateBill(g)*0.10;
}
else
{
return
calculateBill(g);
}
}
public
double
calculateAmmount_Return(Grocery
g)
{
return
ammount_paidcalculateAmmount_Return(g);
}
}
Test Class:
package
semesterproject;
import
java.util.Scanner;
public
class
Test
{
public
static
void
main(String[]
args)
{
Scanner input = new
Scanner(System.in);
Scanner inputString =
new
Scanner(System.in);
Billcalculation
b=new
Billcalculation(34000);
Calculatebill
v=
Calculatebill();
new
//System.out.println(v.addBill(
b));
}
}
Pharmacy Class:
package
semesterproject;
public class Pharmacy extends
Grocery{
//attributes:
private
double
quantiy;
private
double
price;
public
Pharmacy(int
id,
String name, double quantiy,
double
price)
{
super(id,
name);
this.quantiy = quantiy;
this.price
=
price;
}
public
double
getPrice()
{
return
price;
}
public double getQuantiy()
{
return
quantiy;
}
@Override
public double Discount() {
if
(quantiy>=5)
{
return
getPrice()*0.2;
}
else
{
return getPrice();
}
}
}
Download