Video Rental Inventory System
Video Rental Inventory System
Video Rental Inventory System
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;
CODE:
package com.sikshapath;
import java.util.*;
Visit SIKSHAPATH.IN for More
class Video{
String title;
boolean[] flag=new boolean[10];
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: