Question

This is my code. I need the UML for this code My code: public class Main...

This is my code. I need the UML for this code

My code:
public class Main extends FlightManager {


   Stage window;
   Scene scene;
   Button button;
   HBox layout = new HBox(20);
   Label dateTxt, airlineTxt, originTxt, destTxt, clssTxt, scopeTxt, adultsTxt, childTxt;
  
@Override
public void start(Stage stage) { // create the UI and show it here
   window = stage;
window.setTitle("Reservations 2020");
button = new Button("New Flight");
  
VBox group3 = new VBox(10);
dateTxt = Text("", group3);
   airlineTxt = Text("", group3);
   originTxt = Text("", group3);
   destTxt = Text("", group3);
   clssTxt = Text("", group3);
   scopeTxt = Text("", group3);
   adultsTxt = Text("", group3);
   childTxt = Text("", group3);
  
  
  


VBox group1 = new VBox();
  
Text("Airline:", group1);
ChoiceBox<String> airlineSelection = StrCombo(airlines, group1);
  
Text("Destination:", group1);
ChoiceBox<String> destinationSelection = StrCombo(locations, group1);
  
Text("Origin: ", group1);
ChoiceBox<String> OriginSelection = StrCombo(locations, group1);

Text("Scope:", group1);
ChoiceBox<String> scope = StrCombo(flightScopes, group1);
  
Text("Class:", group1);
ChoiceBox<String> flightClass = StrCombo(flightClasses, group1);
  
  
  
  
VBox group2 = new VBox();
  
Text("Adults:", group2);
TextField Adultstf = new TextField();
Adultstf.setText("0");
  
group2.getChildren().add(Adultstf);
  
  
Text("Children:", group2);
TextField Childrentf = new TextField();
Childrentf.setText("0");
group2.getChildren().add(Childrentf);
  
  
  

  
  
  
  
  
button.setOnAction(e -> getChoice( new Flight(airlineSelection.getValue(), OriginSelection.getValue(), destinationSelection.getValue(), flightClass.getValue(), scope.getValue(), Adultstf, Childrentf)));
  
  

VBox group4 = new VBox(10);
group4.getChildren().add(button);
  
  
  
group1.setLayoutX(100);
  
  
layout.getChildren().add(group1);
layout.getChildren().add(group2);
layout.getChildren().add(group4);
layout.getChildren().add(group3);
  
layout.setPadding(new Insets(20, 20, 20, 20));
  
  
scene = new Scene(layout, 800, 500);
window.setScene(scene);
window.show();
}

public static void main(String[] args) {
  
launch();
}
  
private Label Text(String text, VBox g) {
   Label label = new Label();
label.setText(text);
// return label;
if(g != null) {
   g.getChildren().add(label);
} else {
   layout.getChildren().add(label);
}
return label;
}
  

private ChoiceBox<String> StrCombo(String[] val, VBox g) {
  
  
   ChoiceBox<String> combo = new ChoiceBox<>();
   combo.getItems().addAll(val);
   combo.setValue(val[0]);
  
  
   if(g != null) {
       g.getChildren().add(combo);
   }
   else {
       layout.getChildren().add(combo);
   }
  
   return combo;
}
  
  
  
private void getChoice(Flight flight){
   dateTxt.setText("Date: " + flight.date);
   airlineTxt.setText("Airline: " + flight.airline);
   originTxt.setText("Origin: " + flight.origin);
   destTxt.setText("Destination: " + flight.destination);
   clssTxt.setText("Flight Class : " + flight.flightClass);
   scopeTxt.setText("Flight Scope: " + flight.flightScope);
   adultsTxt.setText("Number of Adults: " + flight.numOfAdults);
   childTxt.setText("Number of Children: " + flight.numOfChildren);
  
}
}

public abstract class FlightManager extends Application {

protected Integer[] numChoices = { 0, 1, 2, 3, 4, 5, 6 };

protected String[] airlines = {"American", "United", "Southwest"};

protected String[] locations = {"Chicago", "Houston", "Las Vegas", "Newark", "Indianpolis"};

protected String[] flightClasses = {"FirstClass", "BuisnessClass", "Coach", "Economy Plus"};

protected String[] flightScopes = {"International", "National"};

public class Flight extends FlightManager {
  
  
   public String origin, destination, flightClass, flightScope, date, airline;
   public int numOfAdults, numOfChildren;
  
  
   public Flight(String airline, String origin, String destination, String flightClass, String flightScope, TextField numOfAdults, TextField numOfChildren) {
       this.origin = origin;
       this.destination = destination;
       this.flightClass = flightClass;
       this.flightScope = flightScope;
      
       int atf;
if(tryParseInt(numOfAdults.getText()) == false) {
   Stage errWindow = new Stage();
   errWindow.setTitle("Invalid value");
   Label l = new Label();
   l.setText("Please only use numbers.");
   Button b = new Button();
   b.setText("OK");
   b.setOnAction(e -> errWindow.close());
   VBox layout1 = new VBox();
   layout1.getChildren().add(l);
   layout1.getChildren().add(b);
   layout1.setPadding(new Insets(20, 20, 20, 20));
Scene scene1 = new Scene(layout1, 300, 100);
errWindow.setScene(scene1);
errWindow.show();
   return;
} else {
   atf = Integer.parseInt(numOfAdults.getText());
}
  
int ctf;
if(tryParseInt(numOfChildren.getText()) == false) {
   Stage errWindow = new Stage();
   errWindow.setTitle("Invalid value");
   Label l = new Label();
   l.setText("Please only use numbers.");
   Button b = new Button();
   b.setText("OK");
   b.setOnAction(e -> errWindow.close());
   VBox layout1 = new VBox();
   layout1.getChildren().add(l);
   layout1.getChildren().add(b);
   layout1.setPadding(new Insets(20, 20, 20, 20));
Scene scene1 = new Scene(layout1, 300, 100);
errWindow.setScene(scene1);
errWindow.show();
   return;
} else {
   ctf = Integer.parseInt(numOfChildren.getText());
}
      
      
       this.numOfAdults = atf;
       this.numOfChildren = ctf;
       this.airline = airline;
      
       SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
       Date today = new Date(System.currentTimeMillis());
       date = formatter.format(today);
      
       System.out.println("Date: " + date);
       System.out.println("Origin: " + origin);
       System.out.println("Destination: " + destination);
       System.out.println("Class: " + flightClass);
       System.out.println("Scope: " + flightScope);
       System.out.println("Adults: " + numOfAdults);
       System.out.println("Children: " + numOfChildren);
       System.out.println("Airline: " + airline);
   }
  
   boolean tryParseInt(String value) {
   try {
   Integer.parseInt(value);
   return true;
   } catch (NumberFormatException e) {
   return false;
   }
   }
  

   @Override
   public void start(Stage arg0) throws Exception {
       // TODO Auto-generated method stub
      
   }
  
   //System.out.println();
  

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The UML Diagram for the above code:

«Java Class>> FlightManager (default package) numChoices: Integer airlines: Stringi locations: String flightClasses: Stringi

Add a comment
Know the answer?
Add Answer to:
This is my code. I need the UML for this code My code: public class Main...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • use this code of converting Km to miles , to create Temperature converter by using java...

    use this code of converting Km to miles , to create Temperature converter by using java FX import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.geometry.Pos; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.Button; import javafx.event.EventHandler; import javafx.event.ActionEvent; /** * Kilometer Converter application */ public class KiloConverter extends Application { // Fields private TextField kiloTextField; private Label resultLabel; public static void main(String[] args) { // Launch the application. launch(args); } @Override public void start(Stage primaryStage) { //...

  • Examine the following code and complete missing parts: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets;...

    Examine the following code and complete missing parts: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class NtoThePowerOfN extends Application{ @Override public void start(Stage primaryStage) throws Exception { TextField inputField; TextField outputField; VBox base = new VBox(10); base.setPadding(new Insets(10)); base.setAlignment(Pos.CENTER); // // A: input components - label and text field // // // B: button - to compute the value // // //...

  • Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees...

    Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees Celsius ((F - 32)*5/9). It needs to be JavaFX 1 import javafx.application. Application; 2 import javafx.stage. Stage; 3 import javafx.scene. Scene; 4 import javafx.scene.layout.HBox; 5 import javafx.scene.layout. VBox; 6 import javafx.geometry.Pos; 7 import javafx.geometry.Insets; 8 import javafx.scene.control.Label; 9 import javafx.scene.control. TextField; 10 import javafx.scene.control.Button; 11 import javafx.event. EventHandler; 12 import javafx.event. ActionEvent; 13 14 ** 15 * Kilometer Converter application 16 17 18 public...

  • Can someone please comment this on what the javafx do and how they are implemented? import...

    Can someone please comment this on what the javafx do and how they are implemented? import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.paint.Paint; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class TextPanel extends Application { GridPane grid = null; Text scenetitle = null; Label tDrawLabel = null; Label bsc345Label = null; HBox THBox = null; VBox mVBox = new VBox(2); Stage primaryStage = null; @Override public void start(Stage...

  • You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*;...

    You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; import javafx.geometry.*; public class OrderSystem extends Application implements EventHandler<ActionEvent> { // Attributes for GUI private Stage stage; // The entire window, including title bar and borders private Scene scene; // Interior of window private BorderPane layout; // Add four labels private Label itemLabel = new Label("Item Name:"); private Label numberLabel = new Label("Number:"); private Label costLabel...

  • Please Help, JavaFX assignment. This assignment will focus on the use anonymous inner class handlers to...

    Please Help, JavaFX assignment. This assignment will focus on the use anonymous inner class handlers to implement event handling. Assignment 12 Assignment 12 Submission Follow the directions below to submit Assignment 12: This assignment will be a modification of the Assignment 11 program. This program should use the controls and layouts from the previous assignment. No controls or layouts should be added or removed for this assignment. Add event handlers for the three buttons. The event handlers should be implemented...

  • / Finish the code to make it work import static javafx.application.Application.launch; import java.io.File; import javafx.application.Application; import...

    / Finish the code to make it work import static javafx.application.Application.launch; import java.io.File; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.media.AudioClip; import javafx.stage.Stage; public class JukeBox extends Application { private ChoiceBox<String> choice; private AudioClip[] tunes; private AudioClip current; private Button playButton, stopButton;    //----------------------- // presents an interface that allows the user to select and play // a tune from a drop down box //-----------------------   ...

  • please help me debug this Create a Future Value Calculator that displays error messages in labels.GUISpecificationsStart...

    please help me debug this Create a Future Value Calculator that displays error messages in labels.GUISpecificationsStart with the JavaFX version of the Future Value application presented in chapter 17. Create error message labels for each text field that accepts user input. Use the Validation class from chapter 17 to validate user input.Format the application so that the controls don’t change position when error messages are displayed. package murach.business; public class Calculation {        public static final int MONTHS_IN_YEAR =...

  • # Java import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class Test extends Application {...

    # Java import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class Test extends Application {   @Override // Override the start method in the Application class   public void start(Stage primaryStage) {     // Create a button and place it in the scene     Button btOK = new Button("OK");     btOK.setOnAction(e -> System.out.println("OK 1"));     btOK.setOnAction(e -> System.out.println("OK 2"));     Scene scene = new Scene(btOK, 200, 250);     primaryStage.setTitle("MyJavaFX"); // Set the stage title     primaryStage.setScene(scene); // Place the scene in the stage     primaryStage.show(); // Display the stage...

  • Consider the blowing code snippet Question 4 2 pts 2 pts Canvas XC Question 3 2...

    Consider the blowing code snippet Question 4 2 pts 2 pts Canvas XC Question 3 2 pts Consider the following code snippet public class Hypp extends Application public void start (Stage stapelt Button button new lutton("Calculate"); Label label new Label("Total amount dut) > public class Handler rolesents EventHandler Action vest public void handle (Actiontrent event) label.Text("Hell) > 2 What is wrong with this code? label must be declared as an instance variable. button must be declared as an instance variable...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT