0% found this document useful (0 votes)
80 views9 pages

20BCS9188 Abhishek Pandey EXP 1.2

1. The document describes an experiment to design and implement an inventory control system for a small video rental store using Java. 2. It involves creating two classes - Video to model individual videos and VideoStore to model the store's inventory and functions like adding, checking out, and returning videos. 3. The experiment was conducted by the student and the source code and output are included which demonstrate the functionality of the classes and inventory system.

Uploaded by

OK BOSS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views9 pages

20BCS9188 Abhishek Pandey EXP 1.2

1. The document describes an experiment to design and implement an inventory control system for a small video rental store using Java. 2. It involves creating two classes - Video to model individual videos and VideoStore to model the store's inventory and functions like adding, checking out, and returning videos. 3. The experiment was conducted by the student and the source code and output are included which demonstrate the functionality of the classes and inventory system.

Uploaded by

OK BOSS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Worksheet Experiment 2

Student Name: Abhishek Pandey UID: 20BCS9188


Branch: CSE Section/Group: WM-608/A
Semester: 5th Sem Date of Performance: 16th Aug,2022
Subject Name: PBL in Java Lab Subject Code: 20CSP-321

1. Aim/Overview of the practical:

Design and implement a simple inventory control system for a small video rental store.

2. Task to be done:

The goal of this project is to design and implement a simple inventory control system for
a small video rental store. Define least two classes: a class Video to model a video and a class
VideoStore to model the actual store.
Assume that an object of class Video has the following attributes:
1.A title; 2.a flag to say whether it is checked out or not; and 3. An average user rating.

Add instance variables for each of these attributes to the Video class.
In addition, you will need to add methods corresponding to the following:
1.being checked out; 2. being returned; and 3. receiving a rating.

The VideoStore class will contain at least an instance variable that references an array of videos
(say of length 10). The VideoStore will contain the following methods:
1.addVideo(String): add a new video (by title) to the inventory;
2.checkOut(String): check out a video (by title);
3.returnVideo(String): return a video to the store;
4.receiveRating(String, int) : take a user's rating for a video; and
5.listInventory(): list the whole inventory of videos in the store.
Finally, create a VideoStoreLauncher class with a main() method which will test the functionality
of your other two classes.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

3. Algorithm:

1.Start.
2. make a class with name Video. In this class make variable related to video.
3. make a class with name VideoStore. In this class functions are made for add video, rent video, return video.
4. make a main class with name VideoStoreLauncher. In this class we call all the function with object of the
class.
5. End.

4. Source Code:
import java.util.Scanner;

/*
*Abhishek Pandey
*Chandigarh University
*UID: 20BCS9188
*/

public class Video


{
public String title;
public boolean checked=true;
int avgrating;
public boolean checked()
{
return checked;
}
public void rent()
{
checked=false;
}
public void returned()
{
checked=true;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

System.out.println("Video is returned ");

}
public int getRating()
{
if(avgrating>0)
{
return avgrating;
}
else{
System.out.println(" Rating is not available");
return 0;
}
}
}
class VideoStore extends Video
{
Video v[]=new Video[10]; static
int i=0;
void addVideo(String title) {
v[i]=new Video();
this.title=title;
v[i].title=title;
i++;
System.out.println("Video Added Successfully");
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

void checkOut(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(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() {
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);
Scanner ob=new Scanner(System.in);
v[k].avgrating=ob.nextInt();
}
}
}
public void listInventory(){
if(i==0) {
System.out.println("No Video in Inventory");
}
else {
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

for(int k=0;k<i;k++) {
System.out.println(k+1 +". "+v[k].title+" "+"Rating "+v[k].avgrating+" Availability
"+v[k].checked());
}
}
}
}

class VideoStoreLauncher {

public static void main(String[] args) {


System.out.println("Code by: Abhishek Pandey");
System.out.println("UID: 20BCS9188");
VideoStore vs=new VideoStore();
int ch,uCh,aCh;
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();
}
else if(uCh==2) {
vs.listInventory();
System.out.println("Enter the video Name you want");
title=s.next();
vs.checkOut(title);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

}
else if(uCh==3){
vs.receiveRating();
}
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();
}
if(aCh==2) {
System.out.println("Enter the name of Video");
title=s.next();
vs.addVideo(title);
// vs.listInventory();
}
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"));
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

5. Result/Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Learning outcomes (What I have learnt):

1. Familiar with Environment

2. Basic functions to perform on array and linked list

3. Create table using array

4. Uses of switch case

Evaluation Grid:

Sr. No. Parameters Marks Obtained Maximum Marks


1. Student Performance 12
(Conduct of experiment)
objectives/Outcomes.
2. Viva Voce 10
3. Submission of Work Sheet 8
(Record)
Total 30

You might also like