0% found this document useful (0 votes)
27 views5 pages

JAVA Worksheet 2.1.2.34

Uploaded by

veer371karan
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)
27 views5 pages

JAVA Worksheet 2.1.2.34

Uploaded by

veer371karan
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/ 5

Experiment1.

Student Name: Shivansh Kumar UID: 21BCS8798


Branch:BE-CSE Section/Group: CC-648
Semester: 6 Date of Performance:20-01-2024
Subject Name: Java Lab Subject Code:21CSH-319

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;

public Video1(String name)


{

videoName=name;

}
public String getName()

return videoName;
}
public void doCheckout()

System.err.println("Video "+'"'+ getName()+'"' +" checked out


successfully.");
}
public void doReturn()
{

checkout=true;
System.err.println("Video "+'"'+ getName()+'"' +" returned
successfully.");
}

public void receiveRating(int rating)


{

this.rating=rating;
}

public int getRating()

{
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");

public void doCheckout(String name)

{
if(store[0].videoName.equals(name))

{
store[0].doCheckout();
}
}

public void doReturn(String name)

{
if(store[0].videoName.equals(name))

{
store[0].doReturn();

}
}

public void receiveRating(String name, int rating)

{
if(store[0].videoName.equals(name))

{
store[0].receiveRating(rating);

System.err.println("Rating "+'"'+store[0].getRating()+'"'+" has been mapped


to the

Video ''"+store[0].getName()+'"');

}
public void listInventory() {

System.out.println("------------------------------------------");
System.out.println("Video Name | Checkout Status | Rating");

System.out.println(store[0].getName()+"|" +store[0].getCheckout()+ "|"+


store[0].getRating());

System.out.println("------------------------------------------");

}
}
class VideoStoreLaucher
{

public static void main(String[] args)


{

Scanner input=new Scanner(System.in);

int choice;
VideoStore1 videoStore=new VideoStore1();
do {
System.out.println("MAIN MENU \n=========");

System.out.println("1. Add Videos:");

System.out.println("2. Check Out Video:");


System.out.println("3. Return Video:");

System.out.println("4. Receive Rating:");

System.out.println("5. List Inventory:");


System.out.println("6. Exit:");

System.out.print("Enter your choice(1..6): ");

choice=input.nextInt();
switch (choice) {

case 1:

System.out.println("Enter the name of the video you want


to add: "); videoStore.addVideo(input.next());
break;
case 2:

System.out.print("Enter the name of the video you want to


check out:
");

videoStore.doCheckout(input.next());
break;

case 3:

System.out.print("Enter the name of the video you want to


Return:"); videoStore.doReturn(input.next());
break;
case 4:

System.out.println("Enter the name of the video you


want to Rate: ");
videoStore.receiveRating(input.next(),
input.nextInt()); break;

case 5:
videoStore.listInventory();

break;
case 6:

System.err.println("Enter ...!! Thanks for


using the application"); System.exit(0);
break;
}
}while(!(choice>=6));

input.close();
}

}
4. Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy