Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

casestudyforPractice-Java8features-day2

The document outlines the requirements for a Show Booking System that automates show management by reading show details from a text file and managing seat bookings. It specifies the implementation of various classes and interfaces, including exception handling for invalid seat numbers, unavailable seats, and unknown shows. The system should utilize Java's stream API and time API for processing and displaying show information efficiently.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

casestudyforPractice-Java8features-day2

The document outlines the requirements for a Show Booking System that automates show management by reading show details from a text file and managing seat bookings. It specifies the implementation of various classes and interfaces, including exception handling for invalid seat numbers, unavailable seats, and unknown shows. The system should utilize Java's stream API and time API for processing and displaying show information efficiently.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Practice - Case Study

An organization is interested in automating the process of Show Booking System .The system should be
in a position to accept showName, showTime and seatsAvailable from a text file and store into List
Collection. System should be able to track whether seats are available , reduce no of seats if booking is
done and whether given show name available or not. System should be able to throw appropriate
exceptions like InvalidSeatNumberException, SeatsNotAvailableException and UnknownShowException.

1. Implement populate() method as default method to populate details


from file in ShowManager interface.
2. Use forEach() method of Iterable interface to read show details
in populate method.
3. Use another interface as @FunctionalInterface to implement only
one abstract method to display all show details available.
4. In displayAllShows() method implement stream API to display show
details.
5. Use time api to check show is available for given time
6. Use BufferedReader.lines() to read show details into stream and
process it.

Show.java
package com.cts.bean;
import java.io.Serializable;
public class Show implements Serializable {
private static final long serialVersionUID = 1L;
private String showName;
private String showTime;
private int seatsAvailable;

getters and setters….

List of Exception classes :


InvalidSeatNumberException
SeatsNotAvailableException
UnknownShowException

ShowManager.java Interface:

Class showManager
{public List<Show> populate();
public void bookShow(List<Show> showList, String showName,
String show_time, int noOfSeats);
}
ShowManagerImpl.java

Class showManagerImpl
{ public List<Show> populate() {
should handle FileNotFoundException, IOException,
ClassNotFoundException
}
public void bookShow(List<Show> showList, String showName,
String show_time, int noOfSeats) throws
SeatsNotAvailableException, UnknownShowException,
InvalidSeatNumberException
{……}
}

Show.java
@FunctionalInterface
public interface Show
{ public void displayAllShows();
}

ShowImpl.java
public class ShowImpl
{
public void displayallShows() { …. }

Main.java

class Main {
public static void main(String args[]) {

List<Show> list=new ArrayList<Show>();

ShowManagerImpl dmi=new ShowManagerImpl();


list=dmi.populate("show.txt");
System.out.println("SHOWS ARE AS FOLLOWS::"+list);

…use stream API to display details

try {
dmi.bookShow(list, "Sahi re Sahi", "6.30pm", 3);

System.out.println(list);
}
….. use multi catch blocks.

You might also like