Question
Hi everyone, I am tryng hard to get help on this site with the same problem, It seems very hard for people to understand the
Hi everyone, I am tryng hard to get help on this site with the same problem,
It seems very hard for people to understand the issue. I have a project on purple box, if someone know how the purple box(renting movies ) works, he may help me.
I have all the interfaces ready(each interface has some tips that shows how each method in its implemented class should be written). This is what I got so far(3 interfaces with 3 associated classes):
Interfaces
1)
public interface AdminADT {
/**
* @require need to go through Movie Object
* @ensure adding a Movie Object to Movie Inventory
*/
public void addMovieToInventory(Movie addMovieToInv);
/**
* @require name of movie to be removed
* @ensure move is removed from inventory list
*/
public void removeFromInventory(Movie removeFromInv);
/**
* @require Type double to change price of movie
* @ensure movie price is changed
*/
public void changePrices(double changePrice);
/**
* @require integer amount of movies for discount
* @ensure discount applied to user's cart
*/
public void volumeDiscount(int volDiscount);
/**
* @require string to use as promo code
* @ensure promo code is created that client is able to apply to cart
*/
public void addPromoCode(String addPromo);
/**
* @require boolean to disable/enable unit
* @ensure cart is disabled/enabled
*/
public boolean isEnable(boolean isEnable);
}
2)
public interface MovieADT {
/**
* @require object with movie title exists
* @ensure movie title in type String is returned
*/
public String getTitle();
/**
* @require: title must be a String
* @ensure: Sets the title attribute of the movie class
*/
public void setTitle(String title);
/**
* @ensure: Returns the genre attribute of the movie class
*/
public String getGenre();
/**
* @require genre in type string to be set
* @ensure Genre is set by String that is passed through
*
*/
public void setGenre(String genre);
/**
* @require
* @ensure returns a Date object representing the movie was released
*/
public String getReleaseDate();
/**
* @require : Movie hasDate
* @ensure: valid date
*/
public void setReleaseDate(String date);
/**
* @require: movie is either bluray or not
* @ensure: true | false
*
*/
public boolean getIsBluRay();
/**
* @require: Movie object
* @ensure: isBluray = 0 | 1
*
*/
public void setIsBluRay(boolean bluRay);
/**
* @require: price >= 0
* @ensure: price is not negative
*
*/
public double getPrice();
/**
* @require price must be type double >= 0
* @ensure price is set with type double pass through
*/
public void setPrice(double price);
/**
* @ensure quantity of movie object is returned in type int
*/
public int getQuantity();
/**
* @require: quantity >= 0
* @ensure: valid positive integer
*/
public void setQuantity(int quantity);
/**
* @ensure String representation of Movie is returned
*/
public String toString();
}
3)
public interface PurpleBoxUserInterface{
/**
* @require Movie object needs a title
* @ensure String of movie title is returned
*/
public ArrayList
/**
* @require Movie object must need genre
* @ensure String of movie genre is returned
*/
public ArrayList
/**
* @require
* @ensure Returns all new releases to the user
*/
public ArrayList
/**
* @require search for Blu ray passing in the array
* @ensure Returns the list of bluray movies
*/
public ArrayList
/**
* @require User adding a movie to the cart
* @ensure
*/
public void addMovie(Movie movieName);
/**
* @require adding movie to the user list
* @ensure User will have movies in the cart to check out
*/
public void removeFromCart(Movie movie);
/**
* @require User removing all movies from the cart
* @ensure all movie objects are removed from cart
*/
public void removeAllFromCart();
/**
* @require User checks what's available
* @ensure Returns all available movies to the user
*/
public boolean checkAvailability(Movie movie);
/**
* @require
* @ensure entire cart is checked out to user
*/
public void checkOutMovie(Movie movie);
/**
* @required
* @ensure User returns all movies rented
*/
public void returnMovie(Movie returnMovie);
/**
* @require Apply a certain data type to retrieve a promotional code
* @ensure Applying code to give a client the discount
*/
public void applyCode(String applyCode);
}
implented classes
1) incompleted class, need some hand with code
public class Admin implements AdminADT{
public void addMovieToInventory(Movie addMovieToInv) {
this.addMovieToInventory(addMovieToInv);
}
public void removeFromInventory(Movie removeFromInv) {
this.removeFromInventory(removeFromInv);
}
public void changePrices(double changePrice) {
this.changePrices(changePrice);
}
public void volumeDiscount(int volDiscount) {
this.volumeDiscount(volDiscount);
}
public void addPromoCode(String addPromo) {
this.addPromoCode(addPromo);
}
public boolean isEnable(boolean isEnable) {
return false;
}
}
2) incompleted class, may need some modifications
public class Movie implements MovieADT{
String movieName;
String title;
String genre;
String releaseDate;
double price;
int quantity;
public Movie(String movieName, String title, int quantity, String genre, boolean BluRay, String releaseDate,int price) {
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(String date) {
this.releaseDate = date;
}
public boolean getIsBluRay() {
return false;
}
public void setIsBluRay(boolean bluRay) {
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
3) incomplet
import java.util.ArrayList;
public class PurpleBox implements PurpleBoxUserInterface {
ArrayList
ArrayList
public ArrayList
ArrayList
for(Movie movie : movieList ) {
if(movie.getTitle().equals(movieTitle)) {
returnList.add(movie);
}
}
return returnList;
}
public ArrayList
ArrayList
for(Movie movie : movieList ) {
if(movie.getGenre().equals(movieGenre)) {
returnList.add(movie);
}
}
return returnList;
}
@SuppressWarnings("unlikely-arg-type")
public ArrayList
ArrayList
for(Movie movie : movieList ) {
if(movie.getReleaseDate().equals(releasedYear)) {
releasedYear.add(movie);
}
}
return releasedYear;
}
public ArrayList
ArrayList
for(Movie movie : movieList ) {
if(movie.getIsBluRay()) {
movieType.add(movie);
}
}
return movieType;
}
public void addMovie(Movie movieName) {
movieList.add(movieName);
}
public void removeFromCart(Movie movie) {
cart.remove(movie);
}
public void removeAllFromCart() {
cart.clear();
}
public boolean checkAvailability(Movie movie) {
return movieList.contains(movie);
}
public void checkOutMovie(Movie movie) {
movieList.remove(movie);
}
Hope to read someone soon, thanks in advance.
Step 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