Question: I need help Completing the Programming of a JavaFX Application Using Lambda Expressions, the bold code states where I need to modify the code, the

I need help Completing the Programming of a JavaFX Application Using Lambda Expressions, the bold code states where I need to modify the code, the last answer I received on here did not modify this code at all. I need additional code where the comment area is bolded. I need help completing the programming of a lambda expression event handler of a JavaFX application. The application registers students for courses in a term of study. The application does compile and does run, but it does not produce the expected result as stated in its requirements. The code needs to : Validate the user course selection for registration against the given registration business rules Display either an error with explanation or a registration confirmation message based on your validation of user selection Update and display the current list of valid registered courses and their total credit hours The requirements of this application are as follows. The application is register students for courses in a term of study. The assumptions used by the application are: Each course carries 3 credit hours The program terminates only when the student closes it The program must follow these registration business rules: No registration more than once for the same course No registration for more than 9 credit hours (e.g. no more than 3 courses) The application uses the JavaFX GUI platform for its implementation. Students select from a JavaFX ComboBox menu of courses for which they wish to register. The program use a lambda expression event handler to validate user selection and act accordingly. If the user selection is valid against the registration business rules, the program displays a registration confirmation message to the student for the selected course. Otherwise, the program displays an error message explaining the reason of the invalidation of the selection. The application maintains and displays a current list of registered courses. Additionally, the application maintains and displays a cumulative total credit hours the student has registered for thus far. Use these course codes, in this order, to test your application: IT2230 IT3349 IT2230 IT4782 IT4784 2 Success of this assignment will display a valid message or an invalid message, with reason, for the selected course code. In addition, the application should display and update current list of registered courses and their cumulative total credit hours. Your program interaction should look like the sample interaction video, JAVA FX Register for Course in the Resources.

The code I have to use is:

Course.java

* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package u4a1_javafxregisterforcourse;

/** * * @author omora */ public class Course { private String code = ""; private boolean isRegisterdFor = false; public Course(String code){ this.code = code; } public void setCode(String code){ this.code = code; } public String getCode() { return this.code; } public void setIsRegisteredFor(boolean trueOrFalse){ this.isRegisterdFor = trueOrFalse; } public boolean getIsRegisteredFor() { return this.isRegisterdFor; } @Override public String toString(){ return this.getCode(); } }

JavaFxRegisterforCourse.java * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package u4a1_javafxregisterforcourse;

import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; import javafx.scene.layout.GridPane; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.image.ImageView; import javafx.scene.paint.Color; import javafx.geometry.HPos; import javafx.geometry.VPos; import javafx.scene.layout.RowConstraints; import javafx.scene.control.ComboBox; import javafx.scene.control.TextField;

/** * * @author omora */ public class U4A1_JavaFXRegisterForCourse extends Application { GridPane grid = new GridPane(); Label selectPromptLabel = new Label("Please select a course for which you want to register"); ComboBox coursesComboBox = new ComboBox<>(); Label confirmPromptLabel = new Label(""); Label registeredCoursesPromptLabel = new Label("You are currently registered for"); Label creditHourPromptLabel = new Label("Current total Credit Hours"); Label registeredCoursesLabel = new Label(""); Label creditHoursLabel = new Label("0");

Course choice; int totalCredit = 0;

@Override public void start(Stage primaryStage) {

/* grid.setHgap(0); grid.setVgap(500);

grid.setGridLinesVisible(true); */ RowConstraints row0 = new RowConstraints(); RowConstraints row1 = new RowConstraints(); RowConstraints row2 = new RowConstraints(); RowConstraints row3 = new RowConstraints(); RowConstraints row4 = new RowConstraints(); row0.setPercentHeight(5); row1.setPercentHeight(50); row2.setPercentHeight(10); row3.setPercentHeight(5); row4.setPercentHeight(15);

grid.getRowConstraints().addAll(row0, row1,row2, row3, row4);

grid.setAlignment(Pos.CENTER);

grid.setHgap(5); grid.setVgap(5);

grid.add(selectPromptLabel, 0, 0); grid.setHalignment(selectPromptLabel, HPos.LEFT);

coursesComboBox.getItems().addAll( new Course("IT4782"), new Course("IT4784"), new Course("IT4786"), new Course("IT4789"), new Course("IT2230"), new Course("IT3345"), new Course("IT3349") ); coursesComboBox.setMaxWidth(Double.MAX_VALUE);

grid.add(coursesComboBox, 0, 1); grid.setValignment(coursesComboBox, VPos.TOP);

confirmPromptLabel.setTextFill(Color.RED); grid.add(confirmPromptLabel, 0, 2); grid.setHalignment(confirmPromptLabel, HPos.LEFT); grid.setValignment(confirmPromptLabel, VPos.TOP);

grid.add(registeredCoursesPromptLabel, 0, 3); grid.setHalignment(registeredCoursesPromptLabel, HPos.LEFT); grid.setValignment(registeredCoursesPromptLabel, VPos.TOP);

grid.add(creditHourPromptLabel, 1, 3); grid.setHalignment(creditHourPromptLabel, HPos.LEFT); grid.setValignment(creditHourPromptLabel, VPos.TOP);

grid.add(registeredCoursesLabel, 0, 4); grid.setHalignment(registeredCoursesLabel, HPos.LEFT); grid.setValignment(registeredCoursesLabel, VPos.TOP); registeredCoursesLabel.setStyle("-fx-background-color: #fff600;"); grid.add(creditHoursLabel, 1, 4); grid.setHalignment(creditHoursLabel, HPos.LEFT); grid.setValignment(creditHoursLabel, VPos.TOP); creditHoursLabel.setStyle("-fx-background-color: #fff600;");

Scene scene = new Scene(grid, 500, 500, Color.RED); primaryStage.setTitle("JavaFX Register for Course"); primaryStage.setScene(scene); primaryStage.show(); coursesComboBox.setOnAction(e -> { choice = coursesComboBox.getValue(); // TO DO - Add Code to: // Validate user selection (the choice Course object) // Display a confirmation or error message accordingly // Update display of registered courses and the total credit hours as appropriate

}); }

/** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!