Question
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:
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
k x MavBox Customer CuS -name:String -address:Address -creditCardNumber:String -rentalList:ArrayListcRental> +addRental(Rental rental):Void +toString:Strin ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started