Java Lab Project
Java Lab Project
ELECTRONICS STORE
Made By: Aditya Oberai, Shreedev Ganesh Mishra, Priyank Verma
Objective
The objective of our project is to implement the basic functioning of an application for an electronics
store. We had planned on working on a Point-of-Sale system with a JavaFX UI earlier but faced some
technical issues that we could not resolve in time. We will however be working on a UI with the AWT
package even after submission in order to improve the project.
Aditya worked on the billing aspect of the program in order to implement the file handling
functions and connect them with the functions handling the product purchases.
Shreedev developed the class which contained all the products designed to handle the
product purchases.
Priyank was responsible for implementing OOP principles to connect the Products class and
also designed the UI of the program for the console post the JavaFX issue.
The project has solely been created in core Java. The IDE we used to develop the project was
Netbeans 8.2. The files we generated using file handling to manage the billing are of .TXT format.
Flow Chart of the Project
Important Packages and Classes
The most crucial package used in this project is the “java.io” package. The “java.io” package is what
allows inputting and outputting data to files outside the program. The following classes have been
used from the “java.io” package:
Major Screenshots
Class ElectronicsStore
package electronics_store;
import java.io.*;
/**
*/
bill=0;
repeat='n';
N="";
address="";
name="";
name=br.readLine();
do
int a1 = Integer.parseInt(br.readLine());
switch (a1) {
case 1:
bill=pr.laptop(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 2:
bill=pr.desktop(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 3:
bill=pr.mobilePhone(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 4:
bill=pr.gamingConsole(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 5:
bill=pr.videogame(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 6:
bill=pr.camera(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 7:
bill=pr.mp3Player(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 8:
bill=pr.tablet(bill);
System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();
break;
case 9:
obj.viewcart();
break;
case 10:
System.out.print("\n\nDo you want to close the aplication without going ahead with any
purchases (y/n): ");
char ex=(char)br.read();
br.read();
break;
default:
break;
System.out.print("\n\n");
while(repeat=='y');
if(repeat=='n')
System.out.print("\n\nDo you want to purchase the items in the cart (y/n): ");
char ex=(char)br.read();br.read();
obj.bill_1();
String S;
while(true)
S=ifile.readLine();
if(S==null) break;
ofile.println(S);
ifile.close();
ofile.close();
}
boolean flag=false;
double a;
while(true)
String S=br.readLine();
N=ifile.readLine();
while(N!=null)
a=Double.parseDouble(ifile.readLine());
if((S.toLowerCase()).compareTo(N.toLowerCase())==0)
flag=true;
bill-=a;
else
file.println(N);
file.println(a);
N=ifile.readLine();
file.close();
replace("bill2.txt","bill1.txt");
break;
char f;
double a;
while(true)
N=ifile.readLine();
if(N!=null)
a=Integer.parseInt(ifile.readLine());
else
System.out.print("\nDo you want to remove something from your cart (y/n) : ");
f=(char)br.read();br.read();
ifile.close();
this.bill_2(f);
}
private void bill_2(char f) throws IOException
char n=f;
do
if(n=='y') this.delete();
else this.bill_3();
System.out.print("\nDo you want to remove something else from your cart (y/n) : ");
n=(char)br.read();br.read();
while(n=='y'||n=='n');
String add1=br.readLine();
String add2=br.readLine();
String add3=br.readLine();
String add4=br.readLine();
this.bill_4_printing();
int x=1;
double a;
while(x==1)
N=ifile.readLine();
if(N!=null)
a=Double.parseDouble(ifile.readLine());
else
System.out.println();
break;
double tax=0.05*bill;
double amt=bill+tax;
ifile.close();
System.exit(0);
double a;
while(true)
N=ifile.readLine();
if(N!=null)
a=Integer.parseInt(ifile.readLine());
else
System.out.println();
break;
repeat=(char) br.read();br.read();
Class Products
package electronics_store;
import java.io.*;
/**
*/
public class Products
char r;
int c[]={40000,45000,50000,55000,70000,75000,80000,90000,100000,130000};
String l[] = {"Dell Inspiron 3048","Lenovo Flex 2-14","Dell Inspiron 5048","HP Pavilion 15","HP
Envy 15","Dell Inspiron 7048","Lenovo Y50","MSI GT60","Alienware 15","Alienware 17"};
do
System.out.println("\n\n|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
char r;
int c[]={40000,45000,55000,60000,65000,30000,27000,30000,80000,90000};
do
System.out.println("|-------|---------------------------------|----------------|");
System.out.println("|-------|---------------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r=(char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
char r;
int c[]={14000,10000,21000,25000,30000,40000,43000,50000};
do
{
System.out.println("\n\n|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
{
char r;
int c[]={18000,35000,25000,35000,20000,15000,30000};
do
System.out.println("\n\n|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
System.out.println("|-------|--------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
}
while(r=='y');
ofile.close();
return bill;
char r;
int c[]={2700,3400,1000,1500,2700,3000,3600,1300,1000,2700};
String l[] = {"Far Cry 4 PS3","Batman Arkham Knight PS4","Metal Gear Solid 5 PC","The Witcher 3
PC ","Bloodborne PS4","Mortal Kombat X XBOX One","Mad Max XBOX One","Hitman Absolution
PS3","Need For Speed Rivals PC","FIFA 15 XBOX 360"};
do
System.out.println("\n\n|-------|---------------------------|----------------|");
System.out.println("|-------|---------------------------|----------------|");
System.out.println("|-------|---------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
if(a1>0 && a1<=l.length)
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
char r;
int c[]={5700,6000,7500,10000,14000,12500,26000};
String l[] = {"Canon Powershot IXUS 145","Sony CyberShot DSC W800","Sony CyberShot DSC
W830","Canon PowerShot SX400 IS","Panasonic Lumix DMC-LZ40","Kodak Pixpro AZ361","Sony DSC-
RX100"};
do
System.out.println("\n\n|-------|---------------------------|----------------|");
System.out.println("|-------|---------------------------|----------------|");
System.out.println("|-------|---------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
char r;
int c[]={5200,5300,5300,8700,12000,14700,18000};
String l[] = {"Sony Walkman MWZ-E383 4Gb","Apple iPod Shuffle 2Gb","Philips GoGear Tapp
4Gb","Sony Walkman NWZ-WH303 4Gb","Apple iPod Nano 16Gb","FiiO X3 1Gb","Apple iPod Touch
32Gb"};
do
{
System.out.println("\n\n|-------|-----------------------------|----------------|");
System.out.println("|-------|-----------------------------|----------------|");
System.out.println("|-------|-----------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
while(r=='y');
ofile.close();
return bill;
{
char r;
int c[]={10000,14000,19000,20500,26000,28000,30000};
String l[] = {"Mi Pad","Asus Fonepad 8","Lenovo Yoga 2","Samsung Galaxy Tab A","Samsung
Galaxy Tab 3","Dell Venue 8","Apple iPad Mini 3"};
do
System.out.println("\n\n|-------|-----------------------------|----------------|");
System.out.println("|-------|-----------------------------|----------------|");
System.out.println("|-------|-----------------------------|----------------|");
int a1 = Integer.parseInt(br.readLine());
bill+=c[a1-1];
ofile.println(l[a1-1]);
ofile.println(c[a1-1]);
r = (char)br.read();br.read();
}
while(r=='y');
ofile.close();
return bill;