Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when the account number doesn't fit the format.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class DigitAccountNumberException extends Exception {
17 /**
18 * To satisfy compiler warning.
19 */
20 private static final long serialVersionUID = 5749603824235195376L;
21
22 /**
23 * Throw an exception for when the account number doesn't fit the format
24 */
25 public DigitAccountNumberException() {
26 System.err.println("Please enter an account number that is 8 digits or less:");
27 }
28 }
29
Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when there is an account with the same number.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class DuplicateAccountNumberException extends Exception {
17
18 /**
19 * To satisfy compiler warning.
20 */
21 private static final long serialVersionUID = 5749603824235195376L;
22
23 /**
24 * Throw an exception for when there is an account with the same number
25 */
26 public DuplicateAccountNumberException() {
27 System.err.println("That account number is already used, Please enter another account number :");
28 }
29 }
30
Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when there are insufficient funds.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class InsufficientFundsException extends Exception {
17 /**
18 * To satisfy compiler warning.
19 */
20 private static final long serialVersionUID = 5749603824235195376L;
21
22 //to store the amount the account is short by
23 private double shortAmount;
24
25 /**
26 * Throw exception for when there are insufficient funds.
27 * @param shortAmount How much money you are short by for a withdrawal.
28 */
29 public InsufficientFundsException(double shortAmount) {
30 this.shortAmount = shortAmount;
31 System.err.println("You are unable to withdraw money as you are short $"
32 +String.format("%.1f", shortAmount)+ ".");
33 }
34
35 /**
36 * Return the amount short by.
37 * @return The amount you are short by.
38 */
39 public double getShortAmount() {
40 return shortAmount;
41 }
42 }
43
Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when the account number is negative.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class NegativeAccountNumberException extends Exception {
17
18 /**
19 * To satisfy compiler warning.
20 */
21 private static final long serialVersionUID = 5749603824235195376L;
22
23 /**
24 * Throw an exception when the account number is negative
25 */
26 public NegativeAccountNumberException () {
27 System.err.println("Please enter a positive integer value for the account number :");
28 }
29 }
30
Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when the account number is negative.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class NegativeAccountNumberException extends Exception {
17
18 /**
19 * To satisfy compiler warning.
20 */
21 private static final long serialVersionUID = 5749603824235195376L;
22
23 /**
24 * Throw an exception when the account number is negative
25 */
26 public NegativeAccountNumberException () {
27 System.err.println("Please enter a positive integer value for the account number :");
28 }
29 }
30
Exported from Notepad++
1 // Name: Mostapha Abdelaziz
2 // Class: CST8132 #303
3 //
4 // Assessment: Lab 8
5 // Description: Class to throw an exception, extends exception
6
7 package lab8;
8
9 /**
10 * Throws a more detailed exception, extends Exception. For when the wrong menu option is used.
11 * @author Mostapha Abdelaziz
12 * @version 1.0
13 * @since 1.8
14 * @see Exception
15 */
16 public class WrongMenuException extends Exception {
17
18 /**
19 * To satisfy compiler warning.
20 */
21 private static final long serialVersionUID = 5749603824235195376L;
22
23 /**
24 * Throw an exception when the wrong menu option is used.
25 */
26 public WrongMenuException() {
27 System.err.println("Wrong Menu Selection: Did not receive one of the listed inputs. "
28 + "Please enter one of the listed inputs.");
29 }
30
31 }
32