To get more experience working on complex Java programs combining multiple classes, files, exceptions and the use of the Java API.
For this project, you will create a flash-card like program that will allow users to study things they wish to memorize. The program will represent a flash card containing a question, such as "What is the capital of Morocco?"; and an answer, such as "Rabat".
The program will not ask the user to type the answer in, or check if they got it right. Instead, it will display the question and then just wait for the user to show they're ready by pressing enter. It will then show the user the answer and ask them if they got it right. Since the program is intended for self-study, there's no reason for the user to lie!
The cards will be organized into multiple decks. For instance, we might have one deck for world capitals, another for German verbs, and a third for the names of human bones. Each deck will be stored in a file. The program will let us study the cards in a deck, add new cards to a deck, and create new decks.
This program will also keep track of when each card is due to be studied again. The more somebody gets a question wrong, the more often they will need to review it. Rather than just asking if someone got the question right or wrong, we will actually provide them with four options:
Questions that are easy will not be due again for longer than questions that were difficult, with "correct" ones somewhere in between. Questions the user gets wrong will be repeated again in this same study session until they get them right.
This idea is called Spaced repetition and has been shown to be an effective way to memorize information. The program Anki is an example of a spaced repetition program.
To implement this, each card will store the number of days between reviews. As the user gets the card correct, this number will increase. It will start at 1, then perhaps go to 2, then 4, then 7, then 13, and so on. In addition to storing this number, each Card will store a due date. I recommend using Java's LocalDate class for this purpose.
Each time a user answers a question, the days between study will be updated. There are many ways we can do this, but the following scheme will work pretty well:
numDays = round((numDays + 1) * 1.5)
numDays = round((numDays + 1) * 1.25)
numDays = round((numDays + 1) * 1.1)
numDays = 0
The decks will be stored in a directory called "decks", with a separate file for each deck. The files will have the ".deck" extension. You can look at my decks directory which has three decks. One has some random Spanish words in it, one has all of the capital cities of the world, and one has all of the elements in the periodic table.
Here are the first few lines of decks/spanish.deck:
manzana
apple
4
2023-02-16
false
pasa
raisin
3
2023-02-23
false
The information for each card takes 5 lines:
There is one blank line after every card in the file. This just makes the file easier to read should you open it with a text editor.
Your program provides three main features, which will interact with these deck files:
Here is a design you can use as a starting place for this project.
You may add other methods to the classes as well.
You can download my solution as SRS.jar. You can run this program from within IntelliJ by copying it into your project directory. Then right-click the .jar file and choose "Run SRS.jar":
You can also download the deck files and place them in your project directory so that you can use them for testing.
When writing your program, also be sure to:
You should submit your program by uploading all of the .java files to Canvas.
Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.