SlideShare a Scribd company logo
You can look at the Java programs in the text book to see how
comments are added to programs.
Minimal Submitted Files
You are required, but not limited, to turn in the following
source files:
Assignment6.java (No need to modify)
Movie.java (No need to modify, modified version from the
assignment 4)
Review.java (No need to modify)
CreatePane.java - to be completed
ReviewPane.java - to be completed
You might need to add more methods than the specified ones.
Skills to be Applied:
JavaFX, ArrayList
Classes may be needed:
Button, TextField, TextArea, Label, RadioButton, ListView, and
ActionHandler. You may use other classes.
Here is the Assignmnet6.java:
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);
}
}
Here is Movie.java:
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 = "nMovie Title:tt" + movieTitle
+ "nMovie Length:tt" + length
+ "nMovie Year:tt" + year
+ "n" + bookReview.toString() + "nn";
return result;
}
}
Here is Review.java:
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 = sumOfRatings/numberOfReviews;
}
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:t" + fmt.format(average) + "("
+ numberOfReviews + ")";
return result;
}
}
Here is CreatePane.java:
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
}
Here is ReviewPane.java
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
You can look at the Java programs in the text book to see how commen

More Related Content

PDF
React table tutorial use filter (part 2)
PDF
Workshop 23: ReactJS, React & Redux testing
PPT
3 j unit
ODP
Bring the fun back to java
PDF
need this program in java please and thanks!NOTICE There are NO s.pdf
PPT
Java findamentals1
PPT
Java findamentals1
PPT
Java findamentals1
React table tutorial use filter (part 2)
Workshop 23: ReactJS, React & Redux testing
3 j unit
Bring the fun back to java
need this program in java please and thanks!NOTICE There are NO s.pdf
Java findamentals1
Java findamentals1
Java findamentals1

Similar to You can look at the Java programs in the text book to see how commen (20)

PPT
Unit Testing using PHPUnit
DOC
CS2309 JAVA LAB MANUAL
PDF
Php unit (eng)
PPT
Understanding Annotations in Java
PPTX
Ppt on java basics1
PDF
We will be making 4 classes Main - for testing the code Hi.pdf
PPT
TDD And Refactoring
PDF
Fighting Fear-Driven-Development With PHPUnit
PDF
I really need help on this question.Create a program that allows t.pdf
PDF
From Swing to JavaFX
PDF
PDF
PDF
Test Presentation
PPTX
Java 8 presentation
PDF
Setup Java Path and classpath (from the java™ tutorials essential classes -...
PPTX
Laravel Unit Testing
DOCX
Requirements to get full credits in Documentation1.A descripti
PDF
1669958779195.pdf
PPTX
Lecture 2 Introduction to AWT (1).ppt.hello
PPTX
java150929145120-lva1-app6892 (2).pptx
Unit Testing using PHPUnit
CS2309 JAVA LAB MANUAL
Php unit (eng)
Understanding Annotations in Java
Ppt on java basics1
We will be making 4 classes Main - for testing the code Hi.pdf
TDD And Refactoring
Fighting Fear-Driven-Development With PHPUnit
I really need help on this question.Create a program that allows t.pdf
From Swing to JavaFX
Test Presentation
Java 8 presentation
Setup Java Path and classpath (from the java™ tutorials essential classes -...
Laravel Unit Testing
Requirements to get full credits in Documentation1.A descripti
1669958779195.pdf
Lecture 2 Introduction to AWT (1).ppt.hello
java150929145120-lva1-app6892 (2).pptx

More from anitramcroberts (20)

DOCX
Propose recommendations to create an age diverse workforce.W.docx
DOCX
Prosecuting Cybercrime  The Jurisdictional ProblemIn this discuss.docx
DOCX
PromptTopic Joseph is scheduled to have hip replacement surgery .docx
DOCX
Property TaxThe property tax has been criticized as an unfair ba.docx
DOCX
Prosecutors and VictimsWrite a 2 page paper.  Address the follow.docx
DOCX
Prompt Discuss the recent public policy decisions made in Texas wit.docx
DOCX
Properties of LifeChapter 1 of the text highlights the nine proper.docx
DOCX
Proofread and complete your manual that includes the following ite.docx
DOCX
Proof Reading and adding 5 pages to chapter 2The pre-thesis .docx
DOCX
prompt:Leadership Culture - Describe the leadership culture in ope.docx
DOCX
Prompt  These two poems are companion pieces from a collection by.docx
DOCX
PromptTopic Robert was quite active when he first started colleg.docx
DOCX
PromptTopic Outline the flow of blood through the heart.  Explai.docx
DOCX
PromptTopic Deborah has 2 preschool-age children and one school-.docx
DOCX
PROMPTAnalyze from Amreeka the scene you found most powerfu.docx
DOCX
Prompt What makes a poem good or bad  Use Chapter 17 to identi.docx
DOCX
PromptTopic Anton grew up in France and has come to America for .docx
DOCX
Prompt #1 Examples of Inductive InferencePrepare To prepare to.docx
DOCX
Project This project requires you to identify and analyze le.docx
DOCX
ProjectUsing the information you learned from your assessments and.docx
Propose recommendations to create an age diverse workforce.W.docx
Prosecuting Cybercrime  The Jurisdictional ProblemIn this discuss.docx
PromptTopic Joseph is scheduled to have hip replacement surgery .docx
Property TaxThe property tax has been criticized as an unfair ba.docx
Prosecutors and VictimsWrite a 2 page paper.  Address the follow.docx
Prompt Discuss the recent public policy decisions made in Texas wit.docx
Properties of LifeChapter 1 of the text highlights the nine proper.docx
Proofread and complete your manual that includes the following ite.docx
Proof Reading and adding 5 pages to chapter 2The pre-thesis .docx
prompt:Leadership Culture - Describe the leadership culture in ope.docx
Prompt  These two poems are companion pieces from a collection by.docx
PromptTopic Robert was quite active when he first started colleg.docx
PromptTopic Outline the flow of blood through the heart.  Explai.docx
PromptTopic Deborah has 2 preschool-age children and one school-.docx
PROMPTAnalyze from Amreeka the scene you found most powerfu.docx
Prompt What makes a poem good or bad  Use Chapter 17 to identi.docx
PromptTopic Anton grew up in France and has come to America for .docx
Prompt #1 Examples of Inductive InferencePrepare To prepare to.docx
Project This project requires you to identify and analyze le.docx
ProjectUsing the information you learned from your assessments and.docx

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
RMMM.pdf make it easy to upload and study
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Trump Administration's workforce development strategy
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
master seminar digital applications in india
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
Yogi Goddess Pres Conference Studio Updates
RMMM.pdf make it easy to upload and study
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Weekly quiz Compilation Jan -July 25.pdf
Microbial disease of the cardiovascular and lymphatic systems
Trump Administration's workforce development strategy
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
2.FourierTransform-ShortQuestionswithAnswers.pdf
Classroom Observation Tools for Teachers
202450812 BayCHI UCSC-SV 20250812 v17.pptx
master seminar digital applications in india
Chinmaya Tiranga quiz Grand Finale.pdf

You can look at the Java programs in the text book to see how commen

  • 1. You can look at the Java programs in the text book to see how comments are added to programs. Minimal Submitted Files You are required, but not limited, to turn in the following source files: Assignment6.java (No need to modify) Movie.java (No need to modify, modified version from the assignment 4) Review.java (No need to modify) CreatePane.java - to be completed ReviewPane.java - to be completed You might need to add more methods than the specified ones. Skills to be Applied: JavaFX, ArrayList Classes may be needed: Button, TextField, TextArea, Label, RadioButton, ListView, and ActionHandler. You may use other classes.
  • 2. Here is the Assignmnet6.java: 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) {
  • 3. 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);
  • 4. 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); } } Here is Movie.java: public class Movie { private String movieTitle; private int year; private int length; private Review bookReview;
  • 5. //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;
  • 6. } public int getYear() { return year; } public Review getReview() { return bookReview; } //Mutator methods public void setMovieTitle(String aTitle) { movieTitle = aTitle; } public void setLength(int aLength) {
  • 7. 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 = "nMovie Title:tt" + movieTitle + "nMovie Length:tt" + length + "nMovie Year:tt" + year
  • 8. + "n" + bookReview.toString() + "nn"; return result; } } Here is Review.java: 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;
  • 9. 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 = sumOfRatings/numberOfReviews; } else average = 0.0; } //toString() method returns a string containg its review average //and te number of Reviews
  • 10. public String toString() { DecimalFormat fmt = new DecimalFormat("0.00"); String result = "Reviews:t" + fmt.format(average) + "(" + numberOfReviews + ")"; return result; } } Here is CreatePane.java: import java.util.ArrayList; import javafx.scene.layout.HBox; //import all other necessary javafx classes here //---- public class CreatePane extends HBox { private ArrayList movieList;
  • 11. //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. //----
  • 12. //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 //----
  • 13. } //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 //---
  • 14. //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
  • 15. } //end of ButtonHandler class } Here is ReviewPane.java 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
  • 16. { 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
  • 17. //---- //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
  • 18. 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