Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / CS 112 Final Exam Programming Exercise   Programming Languages:  Please download FinalExam_ProgrammingLanguages

CS 112 Final Exam Programming Exercise   Programming Languages:  Please download FinalExam_ProgrammingLanguages

Computer Science

CS 112 Final Exam

Programming Exercise

 

Programming Languages:  Please download FinalExam_ProgrammingLanguages.zip and open

this existing project in IntelliJ.  This application serves as a database of the top programming languages (most followed people) in the world.

The first time the code is executed, you should see the following JavaFX application:

In this app, the user has the ability to add a new programming language or remove an existing one. 

When adding, all fields are required.  An error label will appear next to any text field that is left empty. 

 

A successful addition to the reviews (appears and the end of the list view):

 

 

Now an addition of a Functional programming language (Haskell):

 

 

 

 

 

Finally, when the app closes, all data is written to (and read from) a binary file for persistence.  Here are the steps we’ll need to accomplish these features:

 

[10 points] Open ProgrammingLanguage.java

  1. Ensure the Programming Language class is Serializable so it may be written to a binary file.
  2. Implement the Comparable interface and override the compareTo method
  3. "Compare" Programming Languages first by name, then organization, then release year.

[5 points] Create child classes: ObjectOriented.java and Functional.java

  1. Ensure both classes are Serializable so they may be written to a binary file.
  2. You do not have to implement the Comparable interface for the child classes.
  3. Please use the class diagram below for details.

 

 

 

Open Controller.java

This Java class utilizes the Singleton design pattern, such that there is only one controller for the entire application.  A controller accepts input from the View (Java FX) and converts it into commands for the Model (Model.java).  Specifically, the Controller will load an ObservableList with Programming Language data from the binary file (using the populateListFromBinaryFile() method) only if the binary file has data, otherwise it will instantiate an empty list.

[5 points] public static Controller getInstance()

  1. If the instance is null, assign it to a new Controller, then check to see if the binary file has data
  2. If so, assign the mAllLanguagesList to the populateListFromBinaryFile() method
  3. Otherwise, assign it to a new observableArrayList()
  4. Finally, create private constructor to enforce Singleton pattern (separate from getInstance())

Open Model.java

This Java class serves as the model (data, calculations and business logic) for our application and will use the binary file file to populate an ObservableList<ProgrammingLanguage>.  Here are the steps needed to create a working data model.

[10 points] public static

ObservableList<ProgrammingLanguage> populateListFromBinaryFile()

  1. Create a File reference to the binary file
  2. Check to see if the binary file has data
  3. If so, instantiate an ObjectInputStream reference to the binary file for reading 4. Create a temp array of Programming Language objects to read from the binary file
  1. Initialize the temp array from the binary file reader.
  2. Add the temp array to the collection of all programming languages (list)
  3. Close the binary file reader.

[10 points] public static boolean

writeDataToBinaryFile(ObservableList<Programming Language> allLanguagesList)

  1. Create a File reference to the binary file
  2. Instantiate an ObjectOutputStream reference to the binary file for writing
  3. Create a temp array of Programming Language objects to read from binary file (length should match list size)
  4. Loop through the temp array and initialize each element to the corresponding one in the list 5. Write the temp array object to the binary file writer
  1. Close the binary file writer and return true.
  2. If an exception occurs, print its message and return false.

Open MainScene.java

This Java class provides the view (the visualization) of nodes which present data from the Controller.  Most of the design has been done for you already (since this is old material), but there are a few new tasks to complete, as follows:

[10 points] public MainScene()

  1. Add the Object Oriented and Functional items to the programming language type combo box
  2. Then add a listener on the selectedItemProperty
  3. If the user selects Object Oriented, change the text of the inheritanceIterationLabel to "Inheritance Type:"
  4. Otherwise, change the text to "Iteration Type:"
  5. Finally, select Object Oriented in the combo box by default.

 

  1. For the language list view, add a listener when the selected item changes.
  2. In the changed(..) method, assign the selectedLanguage to the new value
  3. Disable/enable the removeButton according to whether the selectedLanguage is null

[5 points] private void addLanguage ()

1. If the selected item in the programming language type combo box is "Object Oriented", then instantiate new ObjectOriented object and add it to the list of programming languages 2. Otherwise, instantiate new Functional object and add it to the list of programming languages

  1. Update the display when done.
  2. Clear the inputs (all text fields are cleared and the combo box is set to “Object Oriented”)

[5 points] private void removeLanguage ()

  1. If the selected language is null, return
  2. Otherwise, remove the selected language from the list
  3. Update the display when done.

 

 

 

 

 

 

 

Extra Credit Challenge [+6 points]

Create MainScene.java

In this Scene, a user will be able to modify any existing programming language.  For extra credit, you will need to create the Scene from scratch and navigate to it from the MainScene whenever the modifyButton is clicked.  Again, you will need to add the modifyButton to the Main Scene.   Here’s a sample transaction with the user:

 

Now the user clicks the ~ Modify Language button, which loads a new ModifyScene 

(for you to create).  Note that all the selected information is preloaded in the text fields.

 

Now the user modifies the data.

 

After clicking the modifyButton, user is returned back to the MainScene, showing the updated data:

Option 1

Low Cost Option
Download this past answer in few clicks

26.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE