Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EDIT THE FOLLOWING JAVA FILES (6 TOTAL) TO MEET THE REQUIREMENTS OF THE UML DIAGRAM POSTED AT THE BOTTOM YOU SHOULD END UP WITH 10

EDIT THE FOLLOWING JAVA FILES (6 TOTAL) TO MEET THE REQUIREMENTS OF THE UML DIAGRAM POSTED AT THE BOTTOM YOU SHOULD END UP WITH 10 FILES WHEN FINISHED

public class Customer { private String name; private String creditCardNumber; private ArrayList rentalList = new ArrayList(); public Customer () { setName(""); setCreditCardNumber(""); }

public Customer(String name, String creditCardNumber) { this.name = name;//change this this.creditCardNumber = creditCardNumber; }

public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCreditCardNumber() { return creditCardNumber; } public void setCreditCardNumber(String creditCardNumber){ this.creditCardNumber = creditCardNumber; }

public ArrayList getRentalList() { return rentalList; }

public void addRental(Rental rental) { rentalList.add(rental); }

public String toString() { return "Name " + name + " Credit Card Number " + creditCardNumber + " Rental List " + rentalList; } }

public class Rental{ private String title; private String rentalCode; private double price; public Rental() { setTitle(""); setRentalCode(""); setPrice(0); } public Rental(String title, String rentalCode, double price) { this.title = title; this.rentalCode = rentalCode; this.price = price; }

public String getTitle() { return title; }

public void setTitle(String title) { this.title = title; }

public String getRentalCode() { return rentalCode; }

public void setRentalCode(String rentalCode) { this.rentalCode = rentalCode; }

public double getPrice() { return price; }

public void setPrice(double price) { this.price = price; }

public String toString() { return " Title " + title + " RentalCode " + rentalCode + " Price " + price; }

}

public class Game extends Rental{ public enum GameType{XBOX, PLAYSTATION, NINTENDO;} private GameType gType = GameType.XBOX; public Game() { super(); }

public Game(String title, String rentalCode, double price, GameType gtype) { super(title, rentalCode, price); this.gType = gtype; }

public GameType getGameType() { return gType; } public void setGameType(GameType gType) { this.gType = gType; } public String toString() { return super.toString() + " Game Type " + gType; } }

public class Movie extends Rental{ public enum MovieType{BLURAY, DVD;} private MovieType mType = MovieType.DVD; public Movie() { super(); }

public Movie(String title, String rentalCode, double price, MovieType mType) { super(title, rentalCode, price); this.mType = mType; }

public MovieType getMovieType() { return mType; } public void setMovieType(MovieType mType) { this.mType = mType; } public String toString() { return super.toString() + " Movie Type " + mType; }

}

public class MavBox{ private ArrayList customerList = new ArrayList(); private ArrayList movieList = new ArrayList(); private ArrayList gameList = new ArrayList(); public MavBox(){ super(); } public ArrayList getCustomerList(){ return customerList; } public ArrayList getMovieList(){ return movieList; } public ArrayList getGameList() { return gameList; } public void addCustomer (Customer customer) { customerList.add(customer); } public void addMovie (Movie movie){ movieList.add(movie); } public void addGame (Game game){ gameList.add(game); } public String toString() { return ("Customer list: " + customerList + "Movie list: " + movieList + "Game list: " + gameList); } }

public class MavBoxTest{ public static void main(String[] args) { //array list for customer, movie, and game ArrayList customerList = new ArrayList(); ArrayList movieList = new ArrayList(); ArrayList gameList = new ArrayList();

//create customers and add to the list Customer c1 = new Customer("Jones","1234-1234-1234-1234"); customerList.add(c1); Customer c2 = new Customer("Smith","6543-6543-6543-6543"); customerList.add(c2);

//create movies and add to the list Movie m1 = new Movie ("Titanic", "1A", 4.99, Movie.MovieType.BLURAY); movieList.add(m1); Movie m2 = new Movie ("Star Wars", "2C", 5.99, Movie.MovieType.DVD); movieList.add(m2); //create games and add to the list Game g1 = new Game("Warcraft", "5D", 3.99, Game.GameType.PLAYSTATION); gameList.add(g1); Game g2 = new Game("Tomb Raider", "12F", 3.59, Game.GameType.NINTENDO); gameList.add(g2); System.out.println("Customer List " + customerList); System.out.println(" Movie List " + movieList); System.out.println(" Game List " + gameList); } }

UML:image text in transcribed

YOU MUST ALSO DO THE FOLLOWING:

Write a program, WriteData, that will have three methods, writeCustomers, writeRentals, writeCustomerRentals.

These will write data to the customers.txt, rentals.txt, and customerrentals.txt respectively.

The following data will be written.

Customer Data:

Jones,123 One Rd,Arlington,Texas,76019,1234-1234-1234-1234

Smith,54 Lane,Dallas,Texas,76003,6543-6543-6543-6543

Willis,793 First Rd,Fort Worth,Texas,76025,6543-1234-8978

Rental Data:

Movie,Titanic,1A,4.99,BLURAY

Movie,Star Wars,2C,5.99,DVD

Game,Warcraft,5D,3.99,PLAYSTATION

Game,Tomb Raider,12F,3.59,NINTENDO

Movie,Raiders of the Lost Ark,12T,1.79,BLURAY

Movie,Split,8R,2.59,BLURAY

Game,Call of Duty,2G,5.99,XBOX

Movie,Sixth Sense,4D,3.25,DVD

Game,Lego Jurassic World,9Q,2.25,PLAYSTATION

Movie,Avengers,9Y,1.59,DVD

Game,Fallout,7W,1.49,NINTENDO

Movie,Titanic,1AD,4.99,DVD

Movie,Sixth Sense,4DB,3.25,BLURAY

Customer Rentals data:

Jones,Movie,1A

Smith,Movie,8R

Willis,Game,12F

Jones,Movie,2C

Smith,Movie,1AD

Willis,Game,7W

Willis,Movie,4D

Baker, Movie,9Y

HINT FOR MAVBOXTEST

image text in transcribed

k x MavBox Customer CuS -name:String -address:Address -creditCardNumber:String -rentalList:ArrayListcRental> +addRental(Rental rental):Void +toString:Strin ArrayList customer):Void ie(Movie movie): Void (Game game):Void ists(0:Boolean rchaseRental(String name, String typ, String code):Void throws CustomerDoesNotExistException String0):String ccabstract Rental itle:String -rentalcode:String price:double Address -street:String -city:String -state:String zip:int >Rental) >Rental(String title, String rentalCode, double price) +getTitle0):String +setTitle(String title):Void +getRentalCode() String +setRentalCode(String rentalCode):Void tgetPrice():double +setPrice(double price):void +calculateCharge):double +toString):String ecinterface> Bill -calculateBill():double complete to standards ame +MovieType: enum[BLURAY,DVD mType:MovieT >Movie() >Movie(String title, int rentalCode, double price, MovieType type) +setMovieType(MovieType type):Void +getMovieType():MovieType +toString():String +GameType:enumXBOX, PLAYSTATION, NINTENDO -gType:GameType orGame Game(String title, int rentalCode, double price, GameType type) +setGameType(GameType type):Void +getGameType():GameType +toString):Strin MavBoxTest mv:MavBox +main(String argsl)Void +readCustomers():Void +readRentals:Void +readCustomerRentals:Void +calculateTotal):String means that it is not public or not private Underline is static calculate Total walks through each customer's rental list, calculates the charges, and returns a String with the customer's name and their total charges. k x MavBox Customer CuS -name:String -address:Address -creditCardNumber:String -rentalList:ArrayListcRental> +addRental(Rental rental):Void +toString:Strin ArrayList customer):Void ie(Movie movie): Void (Game game):Void ists(0:Boolean rchaseRental(String name, String typ, String code):Void throws CustomerDoesNotExistException String0):String ccabstract Rental itle:String -rentalcode:String price:double Address -street:String -city:String -state:String zip:int >Rental) >Rental(String title, String rentalCode, double price) +getTitle0):String +setTitle(String title):Void +getRentalCode() String +setRentalCode(String rentalCode):Void tgetPrice():double +setPrice(double price):void +calculateCharge):double +toString):String ecinterface> Bill -calculateBill():double complete to standards ame +MovieType: enum[BLURAY,DVD mType:MovieT >Movie() >Movie(String title, int rentalCode, double price, MovieType type) +setMovieType(MovieType type):Void +getMovieType():MovieType +toString():String +GameType:enumXBOX, PLAYSTATION, NINTENDO -gType:GameType orGame Game(String title, int rentalCode, double price, GameType type) +setGameType(GameType type):Void +getGameType():GameType +toString):Strin MavBoxTest mv:MavBox +main(String argsl)Void +readCustomers():Void +readRentals:Void +readCustomerRentals:Void +calculateTotal):String means that it is not public or not private Underline is static calculate Total walks through each customer's rental list, calculates the charges, and returns a String with the customer's name and their total charges

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago