Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer Science GUI 00000000 // Assignment #: // Name: Your Name // StudentID: Your ID // Lecture: Your lecture time (e.g., MWF 9:40am) // Description:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Computer Science GUI 00000000 // Assignment #: // Name: Your Name // StudentID: Your ID // Lecture: Your lecture time (e.g., MWF 9:40am) // Description: The Assignment6 class creates a Tab Pane with // two tabs, one for Movie Creation and one for // Movie Review. import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.layout.StackPane; import java.util.ArrayList; public class Assignment6 extends Application { private TabPane tabPane; private CreatePane createPane; private ReviewPane reviewPane; private ArrayList movieList; public void start(Stage stage) { StackPane root = new StackPane(); //movieList to be used in both createPane & reviewPane movieList = new ArrayList(); reviewPane = new ReviewPane(movieList); createPane = new CreatePane(movieList, reviewPane); tabPane = new TabPane(); Tab tab1 = new Tab(); tab1.setText("Movie Creation"); tab1.setContent(createPane); Tab tab2 = new Tab(); tab2.setText("Movie Review"); tab2.setContent(reviewPane); tabPane.getSelectionModel().select(0); tabPane.getTabs().addAll(tab1, tab2); root.getChildren().add(tabPane); Scene scene = new Scene(root, 700, 400); stage.setTitle("Movie Review Apps"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }
// Assignment #: // Name: // StudentID: // Lecture: // Description: The class Movie represents a Movie. public class Movie { private String movieTitle; private int year; private int length; private Review bookReview; //Constructor to initialize all member variables public Movie() { movieTitle = "?"; length = 0; year = 0; bookReview = new Review(); } //Accessor methods public String getMovieTitle() { return movieTitle; } public int getLength() { return length; } public int getYear() { return year; } public Review getReview() { return bookReview; } //Mutator methods public void setMovieTitle(String aTitle) { movieTitle = aTitle; } public void setLength(int aLength) { length = aLength; } public void setYear(int aYear) { year = aYear; } public void addRating(double rate) { bookReview.updateRating(rate); } //toString() method returns a string containg the information on the movie public String toString() { String result = " Movie Title: " + movieTitle + " Movie Length: " + length + " Movie Year: " + year + " " + bookReview.toString() + " "; return result; } }
// Assignment #: // Name: // StudentID: // Lecture: // Description: The class Review represent reviews of a movie. import java.text.DecimalFormat; public class Review { private int numberOfReviews; private double sumOfRatings; private double average; //Constructor to initialize all member variables public Review() { numberOfReviews = 0; sumOfRatings = 0.0; average = 0.0; } //It updates the number of REviews and avarage based on the //an additional rating specified by its parameter public void updateRating(double rating) { numberOfReviews++; sumOfRatings += rating; if (numberOfReviews > 0) { average = sumOfRatingsumberOfReviews; } else average = 0.0; } //toString() method returns a string containg its review average //and te number of Reviews public String toString() { DecimalFormat fmt = new DecimalFormat("0.00"); String result = "Reviews: " + fmt.format(average) + "(" + numberOfReviews + ")"; return result; } }
// Assignment #: Arizona State University CSE205 // Name: Your Name // StudentID: Your ID // Lecture: Your lecture time (e.g., MWF 9:40am) // Description: CreatePane generates a pane where a user can enter // a movie information and create a list of available movies. import java.util.ArrayList; import javafx.scene.layout.HBox; //import all other necessary javafx classes here //---- public class CreatePane extends HBox { private ArrayList movieList; //The relationship between CreatePane and ReviewPane is Aggregation private ReviewPane reviewPane; //constructor public CreatePane(ArrayList list, ReviewPane rePane) { this.movieList = list; this.reviewPane = rePane; //Step #1: initialize each instance variable and set up the layout //---- //create a GridPane hold those labels & text fields //consider using .setPadding() or setHgap(), setVgap() //to control the spacing and gap, etc. //---- //You might need to create a sub pane to hold the button //---- //Set up the layout for the left half of the CreatePane. //---- //the right half of this pane is simply a TextArea object //Note: a ScrollPane will be added to it automatically when there are no //enough space //Add the left half and right half to the CreatePane //Note: CreatePane extends from HBox //---- //Step #3: register source object with event handler //---- } //end of constructor //Step 2: Create a ButtonHandler class //ButtonHandler listens to see if the button "Create a Movie" is pushed or not, //When the event occurs, it get a movie's Title, Year, and Length //information from the relevant text fields, then create a new movie and add it inside //the movieList. Meanwhile it will display the movie's information inside the text area. //It also does error checking in case any of the textfields are empty or non-numeric string is typed private class ButtonHandler implements EventHandler { //Override the abstact method handle() public void handle(ActionEvent event) { //declare any necessary local variables here //--- //when a text field is empty and the button is pushed if ( //---- ) { //handle the case here } else //for all other cases { //---- //at the end, don't forget to update the new arrayList //information on the ListView of the ReviewPane //---- //Also somewhere you will need to use try & catch block to catch //the NumberFormatException } } //end of handle() method } //end of ButtonHandler class }
// Assignment #: Arizona State University CSE205 // Name: Your Name // StudentID: Your ID // Lecture: Your lecture time (e.g., MWF 9:40am) // Description: ReviewPane displays a list of available movies // from which a user can select to reviw. import javafx.scene.control.ListView; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.layout.VBox; import javafx.event.ActionEvent; //**Need to import to handle event import javafx.event.EventHandler; //**Need to import to handle event import java.util.ArrayList; import javafx.scene.layout.HBox; //import all other necessary javafx classes here //---- public class ReviewPane extends VBox { private ArrayList movieList; //A ListView to display movies created private ListView movieListView; //declare all other necessary GUI variables here //---- //constructor public ReviewPane(ArrayList list) { //initialize instance variables this.movieList = list; //set up the layout //---- //ReviewPane is a VBox - add the components here //---- //Step #3: Register the button with its handler class //---- } //end of constructor //This method refresh the ListView whenever there's new movie added in CreatePane //you will need to update the underline ObservableList object in order for ListView //object to show the updated movie list public void updateMovieList(Movie newMovie) { //------- } //Step 2: Create a RatingHandler class private class RatingHandler implements EventHandler { //Override the abstact method handle() public void handle(ActionEvent event) { //When "Submit Review" button is pressed and a movie is selected from //the list view's average rating is updated by adding a additional //rating specified by a selected radio button if (//----) { //---- } } } //end of RatingHandler } //end of ReviewPane class
Application defined in javafk.application Movie CreatePane movieList: ArmayList Movie> reviewPane ReviewPane Assignment6 +CreatePane(ArrayList,ReviewPane) tabPane:TabPane -createPane:CreatePane reviewPane ReviewPane movieList.ArrayList Movie ReviewPane movieList:ArrayList Movie> start Stage)void Review Pane(ArrayList) tupdateMovieList(Movie) RatingHandler ButtonHandler Arizona State University, CSE205 Spring 2019, Assignment6 thandle(ActionEvent)void +handle(ActionEvent):void 2. If a user enters non integer in the field for length or year, and pushes "Create a movie" button, show a message "Incorrect data format." with red color and nothing should be added to the right hand side panel. Movie Review Apps Movie Creation Movie Review Incorrect data fomat Movie Title: Movie Length: Movie Year: Toy Story 81 995 Title Lassie Length eighty Year 1943 Reviews: 0.00(0) Movie Title: Movie Length:2001 Movie Year: Reviews: 0.00(0) Shrek Create a Movie 90 Movie Review Apps Movie Creation Movie Review Incorrect data format Toy Story TitleLassie Length 85 Year one thousand Movie Title Movie Length:8 Movie Year: Reviews: 0.00(0) 1995 Movie Title: Movie Length: Movie Year Reviews: 0.00(0) Shrek 2001 90 Create a Movie Ater entering multiple movies, the GUI will have the folloning appearance. Movie Review Apps Movie Creation x Movie added Movie Tite: Mevie Length: Movie Year Reviews: 0000) Toy Stary 81 1995 Tnie Longth Mavie Tite: Movie Length2001 Shrok Reviews: 0.00m nder the one erhe tab a u er can aelect om those created moves The hs of created mone3 0 d be made us ListView. elow e L a Vie bere e hou dbe 5 fad o burt a for fat nga, poo far average, goo esce en elow hat, there a ould be another button to a m t a tat g The list of movies under the NMavie Reriew tab should be exactly same as the list under "Movie Creation tab. Movie Review Apps Movie Creation Movie Review X movie to give review. d sewc araling: Toy Stary Movie Length:1 Movie Yer: Roviews 000 1905 Movie Length: 2001 90 Reviews g.cop 1Poor_2Fair''-3Average 4Qood . 5Excelent Submt Review A user can choose one movie from the list, by clicking on it. Movie Review Apps Movie Creation Movie Review X se a movie to give a review, and select a rati Movie Title: Toy Story Movie Length: 8 Movie Year: 1995 Reviews: 0.00(0) Movie Title: Movie Length: Movie Year: Reviews: 0.00(0) Shrek 2001 90 1Poor2 Fair 3 Average4 Good 5 Excellent Submit Review Then a user can choose one of the ratings A user can submit a rating for the selected movie by pushing the submit button at the bottom. This should update the average rating for the selected movie Movie Review Apps Movie Creation Movie Review hoose a movie to give a review, and select a rating: Movie Title: Movie Length: Movie Year: Reviews: 4.00(1) Toy Story 81 1995 Shrek Movie Title: Movie Length: Movie Year: Reviews: 0.00(0) 2001 90 1 Poor2 Fair 3 Average 4 Good 5 Excellent Submit Review Movie Review Apps Toy ay Class description Reientane class shonid coatain at least the toltloming intanze ariable: L ist ie thou dhe crszted using the Obeer hieList o ect Then whene er the arryists tp me, the L rtVie r will be da e d 35 et The mlt ze the to tr ng method oftte Mer e clex 1 eply eaca nen. nus me uod 2 ds e pa z enerse lo ien u enableList tzt zs used to create 2 ListV en: e mo eList Till be 0 an updated uoder e Ma se Ceea ca ab and w en. s de e d dus method sho d te ca ed tnat the a dle od the Bu caiu er of e uaea ea e class so the ListView us er e Mar e Rene r" wn are the sa ttrihut yyahe CrvmPowAmry.tzt ontelun. Rmwra:Pansmnmrom, esg class and Application defined in javafk.application Movie CreatePane movieList: ArmayList Movie> reviewPane ReviewPane Assignment6 +CreatePane(ArrayList,ReviewPane) tabPane:TabPane -createPane:CreatePane reviewPane ReviewPane movieList.ArrayList Movie ReviewPane movieList:ArrayList Movie> start Stage)void Review Pane(ArrayList) tupdateMovieList(Movie) RatingHandler ButtonHandler Arizona State University, CSE205 Spring 2019, Assignment6 thandle(ActionEvent)void +handle(ActionEvent):void 2. If a user enters non integer in the field for length or year, and pushes "Create a movie" button, show a message "Incorrect data format." with red color and nothing should be added to the right hand side panel. Movie Review Apps Movie Creation Movie Review Incorrect data fomat Movie Title: Movie Length: Movie Year: Toy Story 81 995 Title Lassie Length eighty Year 1943 Reviews: 0.00(0) Movie Title: Movie Length:2001 Movie Year: Reviews: 0.00(0) Shrek Create a Movie 90 Movie Review Apps Movie Creation Movie Review Incorrect data format Toy Story TitleLassie Length 85 Year one thousand Movie Title Movie Length:8 Movie Year: Reviews: 0.00(0) 1995 Movie Title: Movie Length: Movie Year Reviews: 0.00(0) Shrek 2001 90 Create a Movie Ater entering multiple movies, the GUI will have the folloning appearance. Movie Review Apps Movie Creation x Movie added Movie Tite: Mevie Length: Movie Year Reviews: 0000) Toy Stary 81 1995 Tnie Longth Mavie Tite: Movie Length2001 Shrok Reviews: 0.00m nder the one erhe tab a u er can aelect om those created moves The hs of created mone3 0 d be made us ListView. elow e L a Vie bere e hou dbe 5 fad o burt a for fat nga, poo far average, goo esce en elow hat, there a ould be another button to a m t a tat g The list of movies under the NMavie Reriew tab should be exactly same as the list under "Movie Creation tab. Movie Review Apps Movie Creation Movie Review X movie to give review. d sewc araling: Toy Stary Movie Length:1 Movie Yer: Roviews 000 1905 Movie Length: 2001 90 Reviews g.cop 1Poor_2Fair''-3Average 4Qood . 5Excelent Submt Review A user can choose one movie from the list, by clicking on it. Movie Review Apps Movie Creation Movie Review X se a movie to give a review, and select a rati Movie Title: Toy Story Movie Length: 8 Movie Year: 1995 Reviews: 0.00(0) Movie Title: Movie Length: Movie Year: Reviews: 0.00(0) Shrek 2001 90 1Poor2 Fair 3 Average4 Good 5 Excellent Submit Review Then a user can choose one of the ratings A user can submit a rating for the selected movie by pushing the submit button at the bottom. This should update the average rating for the selected movie Movie Review Apps Movie Creation Movie Review hoose a movie to give a review, and select a rating: Movie Title: Movie Length: Movie Year: Reviews: 4.00(1) Toy Story 81 1995 Shrek Movie Title: Movie Length: Movie Year: Reviews: 0.00(0) 2001 90 1 Poor2 Fair 3 Average 4 Good 5 Excellent Submit Review Movie Review Apps Toy ay Class description Reientane class shonid coatain at least the toltloming intanze ariable: L ist ie thou dhe crszted using the Obeer hieList o ect Then whene er the arryists tp me, the L rtVie r will be da e d 35 et The mlt ze the to tr ng method oftte Mer e clex 1 eply eaca nen. nus me uod 2 ds e pa z enerse lo ien u enableList tzt zs used to create 2 ListV en: e mo eList Till be 0 an updated uoder e Ma se Ceea ca ab and w en. s de e d dus method sho d te ca ed tnat the a dle od the Bu caiu er of e uaea ea e class so the ListView us er e Mar e Rene r" wn are the sa ttrihut yyahe CrvmPowAmry.tzt ontelun. Rmwra:Pansmnmrom, esg class and

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions