0% found this document useful (0 votes)
83 views4 pages

Video Rental Inventory System

The document describes a program to model a video rental inventory system with two classes: Video and VideoStore. The Video class stores attributes of individual videos like title, check-out status, and rating. The VideoStore class manages an array of Video objects, allowing adding, checking out, returning, and rating videos, as well as listing the current inventory. The program is tested by adding 3 videos, rating them, checking them in and out, and listing the inventory after one is rented.

Uploaded by

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

Video Rental Inventory System

The document describes a program to model a video rental inventory system with two classes: Video and VideoStore. The Video class stores attributes of individual videos like title, check-out status, and rating. The VideoStore class manages an array of Video objects, allowing adding, checking out, returning, and rating videos, as well as listing the current inventory. The program is tested by adding 3 videos, rating them, checking them in and out, and listing the inventory after one is rented.

Uploaded by

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

Visit SIKSHAPATH.

IN for More

Question:
A Video Rental Inventory System
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;
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;
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;

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.

CODE:
package com.sikshapath;

import java.util.*;
Visit SIKSHAPATH.IN for More

class Video{
String title;
boolean[] flag=new boolean[10];

int[] user_rating=new int[10];


void being_checkedout(int i)
{
if(flag[i]==true)
flag[i]=false;
}
void being_returned(int j)
{
if(flag[j]==false)
flag[j]=true;
}
void receive_a_rating(int n,int no)
{
user_rating[n]=no;
}
}
class VideoStore extends Video
{
Video obj=new Video();
String[] videos=new String[10];
int[] rate=new int[10];
int i=0;

void addVideo(String title)


{

videos[i++]=title;
}
void checkOut(String nm)
{

int j,index=0;
for(j=0;j<3;j++)
{
if(videos[j].equals(nm))
{
index=j;
}
}
being_checkedout(index);
}
void returnVideo(String nm)
{
Visit SIKSHAPATH.IN for More

int j,index=0;
for(j=0;j<3;j++)
{
if(videos[j].equals(nm))
{
index=j;
}
}
being_returned(index);
}
void receiveRating(int n, int no )
{
rate[n]=no;
receive_a_rating(n,no);
}
void listInventory()
{
int i;

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

if(flag[i]==true)
System.out.println(videos[i]+" " +flag[i]);
}

}
}
public class store extends VideoStore{
public static void main(String args[])
{
VideoStore o=new VideoStore();
Arrays.fill(o.flag, true);
o.addVideo("The Matrix");
o.addVideo("Godfather II");
o.addVideo("Star War Episode IV: A New Hope");
o.receiveRating(0, 4);
o.receiveRating(1, 3);
o.receiveRating(2, 5);
o.checkOut("The Matrix");
o.checkOut("Godfather II");
o.checkOut("Star War Episode IV: A New Hope");
o.returnVideo("The Matrix");
o.returnVideo("Godfather II");
o.returnVideo("Star War Episode IV: A New Hope");
o.checkOut("Godfather II");
o.listInventory();
Visit SIKSHAPATH.IN for More

}
}

OUTPUT:

You might also like