0% found this document useful (0 votes)
73 views6 pages

Simple Video Rental System in Java

The document describes Experiment 2 conducted by the student. The experiment involves designing and implementing an inventory control system for a small video rental store in Java. The code defines a Video class to represent individual videos with attributes like title, check-in/check-out status, and rating. A VideoStore class manages an array of Video objects, allowing adding, renting, returning and listing videos as well as collecting user ratings. A VideoStoreLauncher class provides a menu-driven interface for users to interact with the system as customers or administrators.

Uploaded by

Gaurav Yadav
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)
73 views6 pages

Simple Video Rental System in Java

The document describes Experiment 2 conducted by the student. The experiment involves designing and implementing an inventory control system for a small video rental store in Java. The code defines a Video class to represent individual videos with attributes like title, check-in/check-out status, and rating. A VideoStore class manages an array of Video objects, allowing adding, renting, returning and listing videos as well as collecting user ratings. A VideoStoreLauncher class provides a menu-driven interface for users to interact with the system as customers or administrators.

Uploaded by

Gaurav Yadav
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

Experiment 2

Student Name: Gaurav UID: 20BCS6806


Branch: AIML Section/Group: 20AIML5-B
Semester: 4th Date of Performance:18/02/22
Subject Name: PROJECT-BASED LEARNING Subject Code: 20CSP-287
IN JAVA LAB

1. Aim/Overview of the practical

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

2. Code:
package [Link];
import [Link];
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;
[Link]("Video is returned ");
}

public int getRating() {


if (avgRating > 0) {
return avgRating;
} else {
[Link](" Rating is not available");
return 0;
}
}
}

class VideoStore extends Video {


static int i = 0;
Video[] v = new Video[10];

void addVideo(String title) {


v[i] = new Video();
[Link] = title;
v[i].title = title;
i++;
[Link]("Video Added Successfully");
}

void checkOut(String title) {


for (int k = 0; k < i; k++) {
if (v[k].[Link](title)) {
if (v[k].checked()) {
v[k].rent();
[Link]("Video is rented");
} else {
[Link]("Sorry Video not available");
}
}
}
}

void returnVideo(String title) {


if (i == 0) {
[Link]("You have no video to return");
}
for (int k = 0; k < i; k++) {
if (v[k].[Link](title)) {
v[k].checked = true;
}
}
}

public void receiveRating() {


if (i == 0) {
[Link]("No Video inInventory");
} else {
for (int k = 0; k < i; k++) {
[Link]("Enter the rating for movie" +
v[k].title);
Scanner ob = new Scanner([Link]);
v[k].avgRating = [Link]();
}
}
}

public void listInventory() {


if (i == 0) {
[Link]("No Video in Inventory");
} else {
for (int k = 0; k < i; k++) {
[Link](k + 1 + ". " + v[k].title + " " +
"Rating " + v[k].avgRating + " Availability" + v[k].checked());
}
}
}
}

public class VideoStoreLauncher {


public static void main(String[] args) {
VideoStore vs = new VideoStore();
int ch, uCh, aCh, vno;
String title, choice;
do {
[Link]("=========Menu=========");
[Link]("1. Login as User");
[Link]("2. Login as Admin");
[Link]("Enter Your Choice");
Scanner s = new Scanner([Link]);
ch = [Link]();
do {
switch (ch) {
case 1:
[Link]("1. List Inventory");
[Link]("2. Rent Video");
[Link]("3. Enter the rating of
Video");
[Link]("4. Return Video");
uCh = [Link]();
if (uCh == 1) {
[Link]();
} else if (uCh == 2) {
[Link]();
[Link]("Enter the video Name
you want");
title = [Link]();
[Link](title);
} else if (uCh == 3) {
[Link]();
} else if (uCh == 4) {
[Link]();
} else {
[Link]("No such Option is
available");
}
break;

case 2:
[Link]("1. List Inventory");
[Link]("2. Add Video");
aCh = [Link]();
if (aCh == 1) {
[Link]();
}
if (aCh == 2) {
[Link]("Enter the name of
Video");
title = [Link]();
[Link](title);
}
break;
default:
[Link]("Sorry Wrong Choice");
}
[Link]("Do you want to repeat yes/no");
choice = [Link]();
} while ([Link]("yes"));
[Link]("Want to Return to main Menu yes/no");
choice = [Link]();
} while ([Link]("yes"));
}
}
3. Output:
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1.
2.
3.

You might also like