S10_ArabicToRomanGUI_Hard - agarmstrong21/agarmstrong_swd_2019 GitHub Wiki

S10_ArabicToRomanGUI_Hard

Portfolio Home Page

Problem Statement

This problem has Easy, Medium, and Hard versions. You must choose which you are doing. Each sequential version builds on the previous version(s). If you claim credit for one version, you may not also claim credit for the other version as a distinct problem.

The basic underlying problem is the conversion of Arabic numbers (numbers we use every day, e.g. 429) to the equivalent Roman numeral (e.g., CDXXIX), and back. For the Easy and Hard difficulties, your GUI interface will display only two JTextAreas: one for Arabic, and one for Roman numerals. For the Medium difficulty, your interface will display four JTextAreas: two for Arabic to Roman conversion (as in the Easy problem) and two for Roman to Arabic conversion. For the Hard version, the same JTextArea will be used for both input and output (of either type of number).

Easy

Convert from Arabic to Roman only. Typing in the Arabic text area will result in a new value being displayed in the Roman text area only after the user types . The output Roman numerals must be properly formed.

Medium

Easy + have another two text areas that convert from Roman to Arabic only. Typing in the Roman text area will result in a new value being displayed in the Arabic text area only after the user types . You can assume that the input Roman numerals are properly formed.

Hard

Convert numbers in both directions, using only two text areas. You cannot assume input Roman numerals are properly formed and must validate them (“XXXX” would be invalid, as “40” should be “XL”). In addition, as the user types in either text area, the equivalent number in the other text area should be updated in real time as each key is pressed.

Additional Notes

For all parts:

  • You may assume that the user will only type valid digits (Arabic), valid Roman numeral characters, or <back-­‐space>.
  • Your conversion must comply with the rules of “modern” Roman Numerals. See http://en.wikipedia.org/wiki/Roman_numerals for more information.
  • Your program needs to handle the positive integers between 1 and 3999, using only the symbols I, V, X, L, C, D, and M. Your conversion function may NOT consist simply of a table look‐up of 3999 different character strings.

User Documentation

This program creates a GUI that implements two text fields to convert Roman Numerals to Arabic Numbers. ArabicToRoman contains all the logic to keep track of the values inputted and changing them accordingly. Each way compares the values and outputs the respective number in the other text box. You do not need to hit enter ever, whatever number is in the field, it is automatically translated. This program can only take Arabic numbers between 1 and 3999.

Developer Documentation

ArabicToRomanDriver creates the GUI window and starts ArabicToRoman class which contains the logic of the program. Using a GridLayout, there are two JTextFields that state which box it belongs to, and two editable JTextFields that are inputs for the program. Whichever side you pick, when a key is pressed the overrided keyReleased method of KeyListeners calls the translate method which converts the number to the other language. Once the output is created, it posts the number to the respective TextField. keyTyped and keyPressed are not used.

Java Docs

cd ~/git
python -m SimpleHTTPServer&

Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:

python3 -m http.server

Java Docs for S10_ArabicToRomanGUI_Hard

Source Code

Source Code for S10_ArabicToRomanGUI_Hard

⚠️ **GitHub.com Fallback** ⚠️