0% found this document useful (0 votes)
48 views8 pages

Exp-1.2 19BCS1431

This document summarizes a student's completion of an experiment to design a video rental inventory system using Java classes. The student created a Video class to model video objects with attributes like title, check-out status, and rating. A VideoStore class was made to represent the store with an array of Video objects and methods like adding videos, checking videos in/out, and listing inventory. A main method tests adding videos, checking some out, returning them with ratings, and re-listing inventory. The student explained the aim, tasks, code steps, and learning outcomes of designing and implementing this basic video rental tracking system using object-oriented programming principles in Java.
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)
48 views8 pages

Exp-1.2 19BCS1431

This document summarizes a student's completion of an experiment to design a video rental inventory system using Java classes. The student created a Video class to model video objects with attributes like title, check-out status, and rating. A VideoStore class was made to represent the store with an array of Video objects and methods like adding videos, checking videos in/out, and listing inventory. A main method tests adding videos, checking some out, returning them with ratings, and re-listing inventory. The student explained the aim, tasks, code steps, and learning outcomes of designing and implementing this basic video rental tracking system using object-oriented programming principles in Java.
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/ 8

Experiment 1.

2
Student Name: M.Sudharshan UID: 19BCS1431
Branch: CSE Section/Group: NTPP_CI_1A
Semester: 6th Date of Performance: 22/2/2022
Subject Name: PBLJ LAB Subject Code: CSP-358

1. Aim/Overview of the practical:

A Video Rental Inventory System

2. Task to be done/ Which logistics used:


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; Meghana : 19BCS1434 IS-5-B :21/02/22 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. It should allow the following. 1. Add 3 videos: "The Matrix", "Godfather II", "Star Wars
Episode IV: A New Hope". 2. Give several ratings to each video. 3. Rent each video out once and return
it. List the inventory after "Godfather II" has been rented out.
3. Steps for experiment/practical/Code:
import java.util.*;
class Video{

String title; Boolean flag=false; static int rating=0;

class VideoStore

Video[] v=new Video[10]; void addVideo()

Scanner sc=new Scanner(System.in);

System.out.println("\nCode by 19BCS1431\n");

System.out.println("Enter 10 videos to store");

for(int i=0;i<10;i++)

{
v[i]=new Video(); v[i].title=sc.nextLine();

void checkOut(String s)

int c=0;

for(int i=0;i<10;i++)

if(v[i].title.equals(s) && v[i].flag==false) v[i].flag=true;

else c++;

if(c==10)
System.out.println("Video not available or been checked out");

void returnVideo(String s)

int c=0,r;

Scanner sc=new Scanner(System.in); for(int i=0;i<10;i++)

if(v[i].title.equals(s) && v[i].flag==true)

v[i].flag=false;

System.out.println("Give rating 5 or less"); r=sc.nextInt();

if(r<=5) receiveRating(s,r); else

System.out.println("Please rate under 5");


}

else

{ c++;

if(c==10)

System.out.println("Video was never checked out");

void receiveRating(String s,int r)

System.out.println("Thanks for rating the video");


}

void listInventory()

System.out.println("Current Inventory"); for(int i=0;i<10;i++)

if(v[i].flag==false) System.out.println(v[i].title);

class Main{
public static void main(String args[]) {
String s;
Scanner sc=new Scanner(System.in); VideoStore vs=new VideoStore(); vs.addVideo();
System.out.println("Enter a video for checkout"); s=sc.nextLine();
vs.checkOut(s);
System.out.println("Enter a video for checkin"); s=sc.nextLine();
vs.returnVideo(s); vs.listInventory();
}}
4. Result/Output/Writing Summary:
5. Learning Outcomes

1. Understanding the problem statement.


2. Understanding various concepts of the java language.
3. Understanding the problem and solving it

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.
4.

You might also like