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

EXPERIMENT2

The document describes a Java program that implements a simple video rental inventory system with two classes: 1) A Video class to model individual video objects with attributes like title, availability status, and user rating. 2) A VideoStore class to represent the store, allowing adding, checking out, returning videos and listing the current inventory. The program is run, demonstrating adding videos, checking videos in and out, and updating the inventory listing.
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)
72 views3 pages

EXPERIMENT2

The document describes a Java program that implements a simple video rental inventory system with two classes: 1) A Video class to model individual video objects with attributes like title, availability status, and user rating. 2) A VideoStore class to represent the store, allowing adding, checking out, returning videos and listing the current inventory. The program is run, demonstrating adding videos, checking videos in and out, and updating the inventory listing.
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/ 3

Chandigarh University PBLJ LAB CSP 378

EXPERIMENT -2
AIM: 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.

SOURCE CODE:
package demopg;
class Video{
String title;
boolean flag =true;
int averageuserrating;
Video(String name){
title = name;
}
void beingcheckedout(){
flag = false;
}
void beingreturned(){
flag = true;
}
void receivingarating(int num){
averageuserrating = num;
}
public String toString() {
return "Video [title=" + title + ", flag=" + flag + ", averageuserrating="
+ averageuserrating + "]";
}
}
class VideoStore{
Video vobj [] = new Video[10];
int count = 0;
void addVideo(String title){
vobj[count] = new Video(title);
count++;
}
void checkOut(String title){
for(int i = 0; i<count; i++){
if(vobj[i].title.equals(title)){
vobj[i].beingcheckedout();
break;
}
1 }
}
void returnVideo(String title ){
for(int i = 0; i<count; i++){

UID:17BCS1833
Chandigarh University PBLJ LAB CSP 378

if(vobj[i].title.equals(title)){
vobj[i].beingreturned();
break;
}
}
}
void receiveRating(String title , int num){
for(int i = 0; i<count; i++){
if(vobj[i].title.equals(title)){
vobj[i].receivingarating(num);
break;
}
}
}
void listInventory(){
for(int i = 0; i<count; i++){
if(vobj[i].flag == true){
System.out.println(vobj[i]);
}
}
}
}
public class VideoStoreLauncher {
public static void main(String[] args) {
VideoStore vsobj = new VideoStore();
vsobj.addVideo("The Matrix");
vsobj.addVideo("Godfather II");
vsobj.addVideo("Star Wars Episode IV: A New Hope");
vsobj.receiveRating("The Matrix", 4);
vsobj.receiveRating("Godfather II", 3);
vsobj.receiveRating("Star Wars Episode IV: A New Hope", 5);
vsobj.listInventory();
vsobj.checkOut("Godfather II");
System.out.println("============");
vsobj.listInventory();
vsobj.checkOut("Star Wars Episode IV: A New Hope");
System.out.println("============");
vsobj.listInventory();
vsobj.returnVideo("Godfather II");
System.out.println("============");
vsobj.listInventory();
}
2 }

UID:17BCS1833
Chandigarh University PBLJ LAB CSP 378

OUTPUT

UID:17BCS1833

You might also like