2.2k views
3 votes
Multi-Scene JavaFX Application with Objects A sample program Q3Skeleton.java to keep track of 3 best friends as strings has been posted in an announcement. Its home screen shows the friends' names. Its edit screen allows you to change your best friends. Its play screen gives randomly generated suggestion of one friend to play with. You will enhance the skeleton with 3 new features. Feature A below entails the most work. It carries the same weight as features B and C combined. A. Change strings for a friend name in the sample to an object with 2 data attributes. If you choose to build a contact list as shown, the two attributes will be name and phone number. See Figures 1 and 2. B. Read initial data from a file when starting the application and save updated data to the same file when closing the application. - For your own testing, you want to make some changes to the data. Close the application. Opening the app again should show you the changed data saved. C. Add a Refresh button on play screen. Pressing the refresh button will regenrate another friend name. The screen should look like Figure 3. Question 3 Multi-Scene JavaFX Application with Objects A sample program Q3Skeleton.java to keep track of 3 best friends as strings has been posted in an announcement. Its home screen shows the friends' names. Its edit screen allows you to change your best friends. Its play screen gives randomly generated suggestion of one friend to play with. You will enhance the skeleton with 3 new features. Feature A below entails the most work. It carries the same weight as features B and C combined. A. Change strings for a friend name in the sample to an object with 2 data attributes. If you choose to build a contact list as shown, the two attributes will be name and phone number. See Figures 1 and 2 . B. Read initial data from a file when starting the application and save updated data to the same file when closing the application. - For your own testing, you want to make some changes to the data. Close the application. Opening the app again should show you the changed data saved. C. Add a Refresh button on play screen. Pressing the refresh button will regenrate another friend name. The screen should look like Figure 3. Home Screen 1 Peter 2233445 2 Paul 7999997 3 Mary 7788001 Figure 1. The grid pane of Home Screen has 3 columns now. Suggestion: Play with Peter. Figure 3. Play screen has a new refresh button to regenrate friend's name. Tips 1. Testing is important and tricky. In an early version, I had a bug of not saving the edited names in the file if I did not leave the Edit Screen before closing the application. 2. Deciding on the right order to implement the three required is important. 3. For time management, if after spending 30 minutes on this question and you made no progress, you should consider switching to Question 1 or 2.

1 Answer

4 votes

Final Answer:

To enhance the Multi-Scene JavaFX application, you should implement three new features. Feature A involves transforming friend names from strings to objects with two data attributes: name and phone number. Feature B requires reading initial data from a file on application startup and saving updated data to the same file when closing the application. Feature C entails adding a Refresh button on the play screen to regenerate another friend name.

Step-by-step explanation:

For Feature A, you'll need to create a Friend class with attributes for name and phone number, ensuring that the application now deals with instances of this class rather than simple string names. This requires modifying the existing code to incorporate the new class and update the display accordingly.

For Feature B, implement file I/O operations to read and save data. When the application starts, read the initial data from a file, and when it closes, save any updated information back to the same file. This ensures persistent storage of changes made during runtime.

Feature C involves adding a Refresh button to the play screen, triggering the generation of a new friend name. This requires implementing an event handler for the button, ensuring that it updates the display with a randomly selected friend name each time it is pressed. These three features collectively enhance the application's functionality, providing a more dynamic and interactive user experience.

User Alukach
by
8.4k points