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

Experiment 2: Aim/Overview of The Practical

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)
33 views6 pages

Experiment 2: Aim/Overview of The Practical

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
You are on page 1/ 6

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 com.gaurav;
import java.util.Scanner;
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;
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 {


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

void addVideo(String title) {


v[i] = new Video();
this.title = title;
v[i].title = title;
i++;
System.out.println("Video Added Successfully");
}

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 {
for (int k = 0; k < i; k++) {
System.out.println(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 {
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);
} 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);
}
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"));
}
}
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