From 1ddac63b0a82178c11c302f67b1aeb5c38dcbb67 Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:28:35 -0500 Subject: [PATCH] Add exception handling --- src/main/java/InteractiveInterface.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/InteractiveInterface.java b/src/main/java/InteractiveInterface.java index 87d1fa1..ef79319 100644 --- a/src/main/java/InteractiveInterface.java +++ b/src/main/java/InteractiveInterface.java @@ -275,10 +275,16 @@ public class InteractiveInterface { readDepth = sc.nextInt(); System.out.print("\nPlease enter probability of a sequence read error (0.0 to 1.0): "); readErrorRate = sc.nextDouble(); + if(readErrorRate < 0.0 || readErrorRate > 1.0) { + throw new InputMismatchException("The read error rate must be in the range [0.0, 1.0]"); + } System.out.println("\nPlease enter the probability of read error collision"); System.out.println("(the likelihood that two read errors produce the same spurious sequence)"); System.out.print("(0.0 to 1.0): "); errorCollisionRate = sc.nextDouble(); + if(errorCollisionRate < 0.0 || errorCollisionRate > 1.0) { + throw new InputMismatchException("The error collision rate must be in the range [0.0, 1.0]"); + } } System.out.println("\nThe graph and occupancy data will be written to a file."); System.out.print("Please enter a name for the output file: ");