0% found this document useful (0 votes)
55 views3 pages

PBLJ Lab Worksheet 1.2

1) The document is a lab report for a video rental inventory system created in Java. 2) The code defines classes for videos, video stores, and the main class to test the system. 3) Methods are included to add videos, check videos in and out, return videos, and view the current inventory.

Uploaded by

Milan Thind
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)
55 views3 pages

PBLJ Lab Worksheet 1.2

1) The document is a lab report for a video rental inventory system created in Java. 2) The code defines classes for videos, video stores, and the main class to test the system. 3) Methods are included to add videos, check videos in and out, return videos, and view the current inventory.

Uploaded by

Milan Thind
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/ 3

Worksheet 1.

Name: Milan Kamboj UID: 18BCS6701


Branch: BE – CSE Section/Group: 18_IS_10 A
{{{ {{{
Semester: 6 th
Date of Performance: 19th Feb 2021
Subject Name: PBLJ Lab Subject Code: CSP-358

Aim: Video Rental Inventory System.

Code (Java):
package pkg;

import java.util.*;

class video {
String title;
boolean[] flag = new boolean[10];
int[] userRating = new int[10];

void beingCheckedOut(int ch) {


if (flag[ch])
flag[ch] = false;
}

void beingReturned(int re) {


if (!flag[re])
flag[re] = true;
}

void receiveARating(int num, int no) {


userRating[num] = no;
}
}

class videoStore extends video {


video obj = new video();
String[] videos = new String[10];
int[] rate = new int[10];
int t = 0;

void addVideo(String title) {


18BCS6701 18_IS_10 A
videos[t++] = title;
}

void checkOut(String num) {


int ch, index = 0;

for (ch = 0; ch < 3; ch++) {


if (videos[ch].equals(num)) {
index = ch;
}
}
beingCheckedOut(index);
}

void returnVideo(String num) {


int rev, index = 0;

for (rev = 0; rev < 3; rev++) {


if (videos[rev].equals(num)) {
index = rev;
}
}
beingReturned(index);
}

void receiveRating(int num, int no) {


rate[num] = no;
receiveARating(num, no);
}

void listInventory() {
int li;

for (li = 0; li < 3; li++) {


if (flag[li])
System.out.println(videos[li] + " " + flag[li]);
}
}
}

public class cls extends videoStore {


18BCS6701 18_IS_10 A
public static void main(String[] args) {
videoStore obj = new videoStore();
Arrays.fill(obj.flag, true);

obj.addVideo("The Matrix");
obj.addVideo("Godfather II");
obj.addVideo("Star War Episode IV: A New Hope");

obj.receiveRating(0, 4);
obj.receiveRating(1, 5);
obj.receiveRating(2, 4);

obj.checkOut("The Matrix");
obj.checkOut("Godfather II");
obj.checkOut("Star War Episode IV: A New Hope");

obj.returnVideo("The Matrix");
obj.returnVideo("Godfather II");
obj.returnVideo("Star War Episode IV: A New Hope");

obj.checkOut("Godfather II");

obj.listInventory();
}
}

Output: Screenshot

18BCS6701 18_IS_10 A

You might also like