Experiment 2: Design and Implement A Simple Inventory Control System For A Small Video Rental Store
Experiment 2: Design and Implement A Simple Inventory Control System For A Small Video Rental Store
Experiment 2: Design and Implement A Simple Inventory Control System For A Small Video Rental Store
AIM:
Design and implement a simple inventory control system for a small video rental store.
Tasks To Be Done:
Design and implement a simple inventory control system for a small video rental store.
Apparatus
● Any Java IDE E.g.: Eclipse, IntelliJ
● Java JDK Installed on System
CODES:
Video_6116 Class:
import java.util.Scanner; class
Video_6116 { public String
title_6116; public boolean
checked=true;
int avgrating_6116; public String
title; public boolean checked() {
return checked; } public void
rent() { checked=false; } public
void returned() { checked=true;
System.out.println("Video is returned "); } public int
getRating_6116() { if(avgrating_6116>0) {
return avgrating_6116; }
else { System.out.println("
Rating is not available");
return 0; }
}
}
VideoStore_6116 Class:
import java.util.Scanner; class VideoStore_6116 extends
Video_6116 { Video_6116 v[]=new Video_6116[10];
private String title; static int i=0; void addVideo_6116(String
title) {
v[i]=new Video_6116();
this.title=title; v[i].title=title;
i++;
System.out.println("Video Added Successfully"); } void
checkOut_6116(String title) { for(int k=0;k<i;k++) {
if(v[k].title.equalsIgnoreCase(title)) { if(v[k].checked()) {
v[k].rent();
System.out.println("Video is rented"); } else {
System.out.println("Sorry Video not available"); }
}
}
}
void returnVideo_6116(String title) { if(i==0) {
System.out.println("You have no video to return"); } for(int
k=0;k<i;k++) { if(v[k].title.equalsIgnoreCase(title)) {
v[k].checked=true; }
}
}
public void receiveRating_6116() { if(i==0) {
System.out.println("No Video inInventory"); } else { for(int
k=0;k<i;k++) {
System.out.println("Enter the rating for movie"+v[k].title);
@SuppressWarnings("resource") Scanner ob=new
Scanner(System.in); v[k].avgrating_6116=ob.nextInt(); }
}
}
public void listInventory_6116() { if(i==0) {
System.out.println("No Video in Inventory"); } else {
for(int k=0;k<i;k++) {
System.out.println(k+1 +". "+v[k].title+" "+"Rating "+ v[k].avgrating_6116 +
"Availability"+v[k].checked()); }
}
}
}
Main_6116 Class:
import java.util.Scanner; public class Main_6116 { public
static void main(String[] args) {
VideoStore_6116 vs=new VideoStore_6116(); int
ch,uCh,aCh,vno; String title,choice; do {
System.out.println("=========Menu=========");
System.out.println("1. Login as User");
System.out.println("2. Login as Admin");
System.out.println("Enter Your Choice"); Scanner s=new
Scanner(System.in); ch=s.nextInt(); do { switch(ch) {
case 1: System.out.println("1. List Inventory");
System.out.println("2. Rent Video");
System.out.println("3. Enter the rating of Video");
System.out.println("4. Return Video"); uCh=s.nextInt();
if(uCh==1) { vs.listInventory_6116(); } else if(uCh==2) {
vs.listInventory_6116();
System.out.println("Enter the video Name you want");
title=s.next(); vs.checkOut_6116(title); } else if(uCh==3) {
vs.receiveRating_6116(); } else if(uCh==4) { vs.rent(); }
else {
System.out.println("No such Option is available"); } break;
case 2:
System.out.println("1. List Inventory");
System.out.println("2. Add Video");
aCh=s.nextInt(); if(aCh==1) {
vs.listInventory_6116(); } if(aCh==2) {
System.out.println("Enter the name of Video");
title=s.next(); vs.addVideo_6116(title); }
break; default:System.out.println("Sorry Wrong Choice"); }
System.out.println("Do you want to repeat yes/no");
choice=s.next(); }
while(choice.equalsIgnoreCase("yes"));
System.out.println("Want to Return to main Menu yes/no"); choice=s.next(); }
while(choice.equalsIgnoreCase("yes")); }
}
LEARNING OUTCOMES:
1. Learned how to use else if ladder in Java
2. Learned how to use inheritance to make a management system
3. Learned how to use boolean values in Java
4. Learned how to make a menu driven program
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):