Sunteți pe pagina 1din 2

Input/Output Java P1 Write a program for managing videocassettes and DVDs in a chain of movie rental stores (like Blockbuster

or Hollywood Video). All stores in the chain use the same rental rating policy: - regular daily rate for a one day rental; - weekend daily rate requires a 2-day minimum rental and has a 4-day maximum rental restriction; - weekly rate requires a 5-day minimum rental and 10-day maximum rental restriction; - monthly rate requires a rental of more than 10 days. A rental store has a name (e.g. Blockbuster Line 5) and stores a number of items. Each store is represented by an instance of a class Store . At the start time the Store instance loads information about its items from a text file (e.g. BBLine5.txt). Each item is represented in memory as an instance of an Item class with the following attributes: - the item unique identifier (a sequence of 10 digits) - the movie title - the item type (1 if videocassette or 2 if DVD) - the item price (in euros) - a boolean information if the item is rented or available - rental date, non-null only if the item is rented, - number days for the rental, non-zero only if the item is rented. The line structure of the file is presented in the following table: File line Blockbuster Line 5 1.5 1.25 1.1 1 387 1015778890 Gone with the Wind 2 28.25 rented 15/09/2005 6 1028789876 Eyes Wide Shut 1 14.70 available null 0 ..... Meaning The store name The regular daily rate The weekend rate The weekly rate The monthly rate The number of items in the store Item identifier Movie title A DVD item The DVD price The item is in rent The date of rental beginning Number of rental days Item identifier Movie title A videocassette item The videocassette price The item is available The date of rental Number of rental days

The behaviour of Item class includes one or more constructors, methods get/set (as required by information hiding principle), and the following other functionalities: - verifies if the current Item object is available or in rent, - computes the number of days after which the current item will be available again (0 if the item is already available), - converts the current object in a string for pretty-printing. The behaviour of the Store class includes at least a constructor with the file name as a parameter and the following functionalities: - adds a new item in the store; - eliminates a damaged or lost item; - saves all items on the hard disk; - provides an available item having a given title and a given item type; if none such item is available, the method returns null; - computes after how many days an item with a given title and a given type will be available; - computes the value of all items owned by the store; - converts the information contained in a Store instance in a string for pretty-printing; - computes the amount of rental for a given number of rental days. In order to test the two classes write a main() method which: 1. creates a Store instance using a file name parameter, 2. lists all items in the store, 3. adds a new item at the store with the same name and type of other items and 6-day rental, 4. prints the price of a 6-day rental, 5. prints the number of days the customer should wait to rent an item with the name and type of the added item, 6. prints the global value of all items owned by the store, and 7. saves on hard disk all items in the store. P2. O companie feroviar face caltorii ntre orasele unei ri. Compania ofer trei tipuri de servicii: locale,
rapide i expres. Taxele percepute de companie sunt 10RON/km pentru serviciile locale, 12RON/km pentru serviciile rapide i 15RON/km pentru serviciile expres. Compania pastreaz o eviden a tuturor clatoriilor fcute. In acest an aceste date sunt ptrate n fiierul calatorii.text ce contine informatiile aranjate n urmatorul format:
Oras plecare_oras destinatie_distanta parcursa_numar pasageri_serviciu_data

unde cmpul data contine ziua/luna n care are loc cltoria. Costurile companiei pentru folosirea trenurilor sunt de 100RON pentru fiecare cltorie i n plus 25RON pentru fiecare KM parcurs. S se scrie un program care citete din fisier si afiseaz urmtoarele informatii: - numrul de trenuri - numarul de trenuri din luna anterioara rularii programului; - numarul de trenuri rapide din luna anterioara rularii programului; - numarul total de pasageri care au mers cu cel putin un tren al companiei n anul current; taxele totale platite de pasageri; - Procentul de profit obtinut de companie de pe urma trenurilor locale. - Pentru fiecare tren, profitul si pierderea calculate pe fiecare calatorie; iesirea ar trebui sa fie o secventa de linii de genul: 14/5 Constanta-Bucuresti: pierdere 234.6 17/5 Bucuresti-Timisoara: profit 12.6

S-ar putea să vă placă și