JAVA Worksheet 2.1.2.34
JAVA Worksheet 2.1.2.34
1. Aim: Design and implement a simple inventory control system for a small video
rental store.
2. Objective: 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.
3. Code:
import java.util.Scanner;
class Video1
{
String videoName;
boolean checkout;
int rating;
videoName=name;
}
public String getName()
return videoName;
}
public void doCheckout()
checkout=true;
System.err.println("Video "+'"'+ getName()+'"' +" returned
successfully.");
}
this.rating=rating;
}
{
return rating;
}
public boolean getCheckout()
{
return checkout;
}
}
class VideoStore1
{
Video1[] store;
public VideoStore1()
{
store=new Video1[5];
}
public void addVideo(String name)
store[0]=new Video1(name);
System.err.println("Video "+'"'+store[0].getName()+'"'+" added successfully");
{
if(store[0].videoName.equals(name))
{
store[0].doCheckout();
}
}
{
if(store[0].videoName.equals(name))
{
store[0].doReturn();
}
}
{
if(store[0].videoName.equals(name))
{
store[0].receiveRating(rating);
Video ''"+store[0].getName()+'"');
}
public void listInventory() {
System.out.println("------------------------------------------");
System.out.println("Video Name | Checkout Status | Rating");
System.out.println("------------------------------------------");
}
}
class VideoStoreLaucher
{
int choice;
VideoStore1 videoStore=new VideoStore1();
do {
System.out.println("MAIN MENU \n=========");
choice=input.nextInt();
switch (choice) {
case 1:
videoStore.doCheckout(input.next());
break;
case 3:
case 5:
videoStore.listInventory();
break;
case 6:
input.close();
}
}
4. Output: