Java Programming with JavaFX
CSCI 428 – Spring 2022 Final Project
100 points + 10 bonus points
Note: This is an individual assignment. Each student MUST complete the work on his/her own. Any code sharing/plagiarism is not tolerated.
Overview
This project consists of two tasks. The goal is to explore how to design various class through encap- sulation, inheritance, composition, and polymorphism, to examine how to create GUI applications using JavaFX. Glance at “What to Submit” when you start working on a task so that you know what information to provide from each task.
Submission Example
CSCI428-project-XX
CSCI428-project-XX.doc
Task1
quiz.txt
newquiz.txt
Base.java
...
MultiChoiceQuestion.java
Task1XX.java
Task2
task2aXX.java
task2bXX.java
task2cXX.java
task2dXX.java
ClockPaneXX.java
README.txt
What to Submit
1. One doc file “CSCI428-project-XX.doc” including the text source code and screenshots of the outputs of all programs. Please replace XX with your first name and last name. You can copy/paste the text source code from Eclipse, IntelliJIDEA, or other IDEs into the doc file. Hopefully, based on the screen snapshots of the output, you can show that your programs passed tests and were well.
2. Java class files for all programs. In well-defined programs, proper comments are required. For programs without comments, they will be deducted greatly in grade.
– For task 1, there are 7 java and 2 txt files.
– For task 2, there are just 5 java files including task2a-dXX.java and ClockPane.java.
3. Note that if any program or code does not work, you can explain the status of the program or code and then attach your explanation and description in a file “README.txt”.
4. Optional. Anything you want to attract the attention of instructor in grading.
Task 1 (50 points): (Quiz Application) Using classes and class inheritance, design a Quiz
(a) Design a interface Base that contains methods setText to set the text of question, setAnswer to set the answer of question, checkAnswer to check a given response for correctness, and display to display the text of question. Save it as Base.java.
(b) Design a class Question that contains two private data fields: text and answer and imple- ments the defined interface Base. Save it as Question.java.
(c) Design a class ChoiceQuestion that inherits from the Question class and haves a new data field choices that could store various choices for its question. The data field choices can be one of Java collection like ArrayList, LinkedList, Set, or Map. A new method addChoice should be defined for adding new answer choices. The display method should be override to show the choices of question so that the respondent can choose one of them. You can also consider to define other accessor and mutator methods if needed. Save it as ChoiceQuestion.java.
(d) Provide toString methods for the Question and ChoiceQuestion classes.
(e) Add a class NumericQuestion to the question hierarchy. If the response and the expected answer differ by no more than 0.01, accept the response as correct. Save it as NumericQues- tion.java.
(f) Add a class FillInQuestion to the question hierarchy. Such a question is constructed with a string that contains the answer, surrounded by ” ”, for example, ”The inventor of Java was James Gosling ”. The question should be displayed as
”The inventor of Java was ” . Save it as FillInQuestion.java.
(g) Add a class MultiChoiceQuestion to the question hierarchy of that allows multiple correct choices. The respondent should provide all correct choices, separated by spaces. Provide instructions in the question text. Save it as MultiChoiceQuestion.java.
(h) Design a test program to test your designs. The program should have a list including all objects of classes you have defined in this task. You should demonstrate two ways to create objects in this program by reading ”quiz.txt” and using a Scanner for reading console input. Use a loop to display all the objects of different classes. In the end, output all questions and corrected answers to a file ”newquiz.txt” using a PrintWriter. Save it as Task1XX.java.
Grading Rubric
– 5 points for each class.
– 5 points for using the Keyword super, defining constructor properly, reading and writing data from/to files correctly.
– 5 points for meeting all requirements
– 5 points for the test program.
– 5 bonus points for drawing a UML diagram showing the dependencies between the defined classes by referring to the examples at shorturl.at/jpGLW and shorturl.at/mnAG6.
Task 2 (50 points): Write Four(4) GUI programs using JavaFX (not Java AWT or Swing) to finish the following sub-tasks:
(a) Displays a 10-by-10 square matrix, as shown in Fig. 1 Each element in the matrix is 0 or 1, randomly generated. Display each number centered in a text field. Use TextField’s setText
method to set value 0 or 1 as a string. Erite a JavaFX program and save the java program as Task2aXX.java.
(b) Based on Task2(a), write a program that displays a checkerboard in which each white and black cell is a Rectangle with a fill color black or white, as shown in Fig. 2. Save the java program as Task2bXX.java.
(c) Draw a detailed clock: Modify the ClockPane class provided to draw the clock with more details on the hours and minutes, as shown in Fig. 3. Save the java file as Task2cXX.java.
(d) Displays two clocks. The hour, minute, and second values are 02, 35, 20 for the first clock and 20, 30, 15 for the second clock. One example is as shown in Fig. 4. Save the java file as Task2dXX.java. Note that If time allows, you can also create animation for a running clock for 10 bonus points.
The figures below show example GUIs of Task2(a)-(d).
Figure 1: Task2(a):10-by-10 square matrix Figure 2: Task2(b):Checkerboard
Figure 3: Task2(c):A detailed clock Figure 4: Task2(d):Two clocks
Grading Rubric
– (5 points) for classes with necessary functions and key details as specified in each subtasks.
– (10 points) for the workable classes and functions without any syntax or runtime errors.
– (10 points) for appropriate comments and screen-shots of GUI outputs of the programs.
Challenges in This Project
1. For 10% extra credit, you are welcome to explore the design of each task. Note: You still have to finish all tasks required by this project.
2. You should install the IntelliJIDEA to facilitate the development of Task 2.
—————x———— Good Luck ————x————–