Fixes "divide by zero" crash
This commit is contained in:
1 parent
a1fb149bec
commit
7c614f331f
4 files changed
+14
-14
No files matched your search
Binary file not shown.
@@ -5,6 +5,7 @@ Should work on any desktop operating system that can run Java 8. Designed and bu
|
||||
|
||||
Changelog:
|
||||
|
||||
- Version 0.4 Alpha - Fixes crash when calculating aspect ratio with "0" as input for width/height
|
||||
- Version 0.3 Alpha - Adds input validation for negative numbers
|
||||
- Version 0.2 Alpha - Bugfix: Crash when entering non-integer characters
|
||||
- Version 0.1 Alpha - Initial Release
|
||||
@@ -12,12 +13,11 @@ Changelog:
|
||||
Known Bugs:
|
||||
|
||||
- UI elements can be misaligned
|
||||
- Running "calculate" with "0" in fields crashes the application
|
||||
|
||||
TODO:
|
||||
|
||||
- Toggle switch for dark mode
|
||||
- Add dark mode in error messages
|
||||
- Add a toggle switch for dark mode
|
||||
- Add dark mode style inside of error messages
|
||||
- Evaluate whether logic to reject numbers that are too large is needed
|
||||
- Come up with a way to auto-merge AARC.jar //TODO(s) into readme
|
||||
|
||||
|
||||
Binary file not shown.
+11
-11
@@ -188,30 +188,30 @@ public class AARC {
|
||||
// Final valid integer testing conditional: means IF both fields are valid integers: do this
|
||||
else {
|
||||
|
||||
// Nested conditionals to display proper error messages based on which fields are negative (therefore, invalid)
|
||||
// Nested conditionals to display proper error messages based on which fields are negative or zero (therefore, invalid)
|
||||
|
||||
// If width and height are both negative: do this
|
||||
if(Integer.valueOf(widthEntry.getText()) < 0 && Integer.valueOf(heightEntry.getText()) < 0) {
|
||||
// If width and height are both negative or zero: do this
|
||||
if(Integer.valueOf(widthEntry.getText()) <= 0 && Integer.valueOf(heightEntry.getText()) <= 0) {
|
||||
|
||||
// Display error message with formatted title
|
||||
JOptionPane.showMessageDialog(null, "It is not possible to have a negative width and height. Please enter positive values and try again.", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Please enter a width and height larger than zero.", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
}
|
||||
// If only width is negative: do this
|
||||
else if(Integer.valueOf(widthEntry.getText()) < 0 && Integer.valueOf(heightEntry.getText()) >= 0) {
|
||||
// If only width is negative or zero: do this
|
||||
else if(Integer.valueOf(widthEntry.getText()) <= 0 && Integer.valueOf(heightEntry.getText()) > 0) {
|
||||
|
||||
// Display error message with formatted title
|
||||
JOptionPane.showMessageDialog(null, "It is not possible to have a negative width. Please enter a positive value and try again.", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Please enter a width larger than zero.", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
}
|
||||
// If only height is negative: do this
|
||||
else if(Integer.valueOf(heightEntry.getText()) < 0 && Integer.valueOf(widthEntry.getText()) >= 0) {
|
||||
// If only height is negative or zero: do this
|
||||
else if(Integer.valueOf(heightEntry.getText()) <= 0 && Integer.valueOf(widthEntry.getText()) > 0) {
|
||||
|
||||
// Display error message with formatted title
|
||||
JOptionPane.showMessageDialog(null, "It is not possible to have a negative height. Please enter a positive value and try again", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Please enter a height larger than zero", "Error", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
}
|
||||
// Final negative number conditional --> If both fields are both valid, positive numbers: do this
|
||||
// Final negative or zero number conditional --> If both fields are both valid, positive, non-zero numbers: do this
|
||||
else {
|
||||
|
||||
// Set display label to result { pass in user entry Integer derived from String to math methods };
|
||||
|
||||
Reference in new issue
Block a user