Java Exp 2
Java Exp 2
Experiment 2
Student Name: Zatch UID:
Branch: BE-CSE Section/Group:
Semester:6 th Date of Performance:
Subject Name: Project Based Learning Subject Code: 22CSH-359
in Java with Lab
1. Aim: The aim 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.
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.
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. 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. Implementation/Code:
1. Video Class:-
class Video {
private String title;
private boolean checkedOut;
private double averageRating;
private int ratingCount;
2. VideoStore Class:-
class VideoStore {
private Video[] videos;
private int count;
3. VideoStoreLauncher Class:-
public class VideoStoreLauncher {
public static void main(String[] args) {
VideoStore store = new VideoStore(10);
store.addVideo("The Matrix");
store.addVideo("Godfather II");
store.addVideo("Star Wars Episode IV: A New Hope");
store.checkOut("Godfather II");
store.returnVideo("Godfather II");
store.listInventory();
}
}
4. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Learning Outcomes:
1. Designed a functional system to manage video rentals, demonstrating the use
of classes and objects in Java.
2. Implemented methods for operations like adding videos, renting out, returning,
and recording user ratings.
3. Applied arrays to store and efficiently manage the video inventory within the
store.
4. Learned to integrate multiple classes and enable seamless interaction among
them in a structured program.
5. Strengthened understanding of object-oriented programming concepts like
encapsulation and method abstraction.