0% found this document useful (0 votes)
2K views12 pages

Experiment - 1.2: Design and Implement A Simple Inventory Control System For A Small Video Rental Store

The document describes designing and implementing a simple inventory control system for a small video rental store. It includes 3 classes - Video, VideoStore, and VideoStoreLauncher. The Video class defines attributes and methods for individual video items. The VideoStore class extends Video and includes methods for adding, renting, returning, and listing inventory. It maintains an array of Video objects. The VideoStoreLauncher class creates a VideoStore object and runs a menu-driven program where users and administrators can perform operations on the inventory.

Uploaded by

405 found
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)
2K views12 pages

Experiment - 1.2: Design and Implement A Simple Inventory Control System For A Small Video Rental Store

The document describes designing and implementing a simple inventory control system for a small video rental store. It includes 3 classes - Video, VideoStore, and VideoStoreLauncher. The Video class defines attributes and methods for individual video items. The VideoStore class extends Video and includes methods for adding, renting, returning, and listing inventory. It maintains an array of Video objects. The VideoStoreLauncher class creates a VideoStore object and runs a menu-driven program where users and administrators can perform operations on the inventory.

Uploaded by

405 found
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/ 12

Experiment -1.

2
Design and implement a simple inventory control system for a small video
rental store
Student Name: UID:
Branch: Section/Group
Semester: Date of Performance:
Subject Name Subject Code:

1. Aim/Overview of the practical:

Design and implement a simple inventory control system for a small video
rental store

2. Task to be done:

Make a simple inventory control system for a small video rental store

3. Apparatus(For applied/experimental sciences/materials based labs):

Jdk, vsCode
4. Algorithm/Flowchart (For programming based labs):

1. start
2. make a class with name Video. In this class make variable related to video.
3. make a class with name VideoStore. In this class functions are made for add video, rent
video, return video. Etc….
4. make a main class with name VideoStoreLauncher. In this class we call all the function with
object of the class.
5. End.

5. Code:

a. code of Video class :


import java.util.Scanner;

public class Video {

    public String title;

    public boolean checked = true;

    int avgrating;

    public boolean checked()

    {

        return checked;

    }

    public void rent() {


        checked = false;

    }

    public void returned()

    {

        checked = true;

        System.out.println("Video is returned ");

    }

    public int getRating()

    {

        if (avgrating > 0)

        {

            return avgrating;

        } else {

            System.out.println(" Rating is not available");

            return 0;

        }

    }

b. code of VideoStore class


import java.util.Scanner;

public class VideoStore extends Video {

    Video v[] = new Video[10];


    static int i = 0;

    void addVideo(String title)

    {

        v[i] = new Video();

        this.title = title;

        v[i].title = title;

        i++;

        System.out.println("Video Added Successfully");

    }

    void checkOut(String title)

    {

        for (int k = 0; k < i; k++)

        {

            if (v[k].title.equalsIgnoreCase(title)) {

                if (v[k].checked()) {

                    v[k].rent();

                    System.out.println("Video is rented");

                }

                else {

                    System.out.println("Sorry Video not available");

                }

            }
        }

    }

    void returnVideo(String title) {

        if (i == 0)

        {

            System.out.println("You have no video to return");

        }

        for (int k = 0; k < i; k++)

        {

            if (v[k].title.equalsIgnoreCase(title)) {

                v[k].checked = true;

            }

        }

    }

    public void receiveRating()

    {

        if (i == 0) {

            System.out.println("No Video inInventory");

        }

        else {

            for (int k = 0; k < i; k++)

            {
                System.out.println("Enter the rating for movie" + v[k].title);

                Scanner ob = new Scanner(System.in);

                v[k].avgrating = ob.nextInt();

            }

        }

    }

    public void listInventory() {

        if (i == 0)

        {

            System.out.println("No Video in Inventory");

        }

        else

        {

            for (int k = 0; k < i; k++)

            {

                System.out.println(k + 1 + ". " + v[k].title + " " + "Rating " +


v[k].avgrating + " Availability" + v[k].checked());

            }

        }

    }

}
c. Code of VideoStoreLauncher class
import java.util.Scanner;

public class VideoStoreLauncher {

  public static void main(String[] args) {


    VideoStore vs = new VideoStore();

    int ch, uCh, aCh, vno;

    String title, choice;

    do {

      System.out.println("=========Menu=========");

      System.out.println("1. Login as User");

      System.out.println("2. Login as Admin");

      System.out.println("Enter Your Choice");

      Scanner s = new Scanner(System.in);

      ch = s.nextInt();

      do {

        switch (ch)

        {

          case 1:
            System.out.println("1. List Inventory");

            System.out.println("2. Rent Video");

            System.out.println("3. Enter the rating of Video");

            System.out.println("4. Return Video");

            uCh = s.nextInt();

            if (uCh == 1)
            {

              vs.listInventory();

            }

            else if (uCh == 2)

            {

              vs.listInventory();

              System.out.println("Enter the video Name you want");

              title = s.next();

              vs.checkOut(title);

            }

            else if (uCh == 3) {

              vs.receiveRating();

            }

            else if (uCh == 4)

            {

              vs.rent();

            }

            else

            {

              System.out.println("No such Option is available");

            }

            break;
          case 2:

            System.out.println("1. List Inventory");

            System.out.println("2. Add Video");

            aCh = s.nextInt();

            if (aCh == 1)

            {

              vs.listInventory();

            }

            if (aCh == 2)

            {

              System.out.println("Enter the name of Video");

              title = s.next();

              vs.addVideo(title);

            }

            break;

          default:
            System.out.println("Sorry Wrong Choice");

        }

        System.out.println("Do you want to repeat yes/no");

        choice = s.next();

      } while (choice.equalsIgnoreCase("yes"));

      System.out.println("Want to Return to main Menu yes/no");


      choice = s.next();

    } while (choice.equalsIgnoreCase("yes"));

  }

10. Result/Output/Writing Summary:


Learning outcomes (What I have learnt):

1. Identify situations where computational methods would be useful.

2. Approach the programming tasks using techniques learnt and write pseudo-code.

3. Choose the right data representation formats based on the requirements of the problem.
4. Use the comparisons and limitations of the various programming constructs and choose the right one for
the task.

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1.
2.
3.

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