diff --git a/secret.txt b/secret.txt
new file mode 100644
index 0000000..ea72b14
--- /dev/null
+++ b/secret.txt
@@ -0,0 +1 @@
+January is the first month and december is the last. Violet is a purple color as are lilac and plum.
\ No newline at end of file
diff --git a/src/main/java/tech/nevets/STEmployeeHours.java b/src/main/java/tech/nevets/STEmployeeHours.java
index 9bc7096..1513bee 100644
--- a/src/main/java/tech/nevets/STEmployeeHours.java
+++ b/src/main/java/tech/nevets/STEmployeeHours.java
@@ -88,6 +88,9 @@ public class STEmployeeHours extends JFrame {
contentPane.add(addHoursField, "cell 1 4");
addHoursButton = new JButton("Add");
addHoursButton.addActionListener(al -> {
+ if (addHoursField.getText().equals("")) {
+ return;
+ }
updateEmpHours(empIdCache.get(), Integer.parseInt(addHoursField.getText()));
updateUI(empIdCache.get());
addHoursField.setText("");
@@ -137,7 +140,7 @@ public class STEmployeeHours extends JFrame {
}
- private class AddUserFrame extends JFrame {
+ private static class AddUserFrame extends JFrame {
public AddUserFrame() {
setResizable(false);
JPanel auContentPane = new JPanel();
@@ -190,4 +193,22 @@ public class STEmployeeHours extends JFrame {
auContentPane.add(cancelButton, "cell 2 4");
}
}
+
+ private static class GrossPayFrame extends JFrame {
+ public GrossPayFrame() {
+ setResizable(false);
+ JPanel gpContentPane = new JPanel();
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ setContentPane(gpContentPane);
+ gpContentPane.setBorder(new EmptyBorder(1, 1, 1, 1));
+ MigLayout layout = new MigLayout(
+ "",
+ "[][fill][]",
+ "[][][][][][]"
+ );
+ gpContentPane.setLayout(layout);
+
+
+ }
+ }
}
diff --git a/src/main/java/tech/nevets/STSearchArray.java b/src/main/java/tech/nevets/STSearchArray.java
new file mode 100644
index 0000000..c163a97
--- /dev/null
+++ b/src/main/java/tech/nevets/STSearchArray.java
@@ -0,0 +1,72 @@
+package tech.nevets;
+
+/**
+ * This class tells you which grades you achieved 100%'s on
+ */
+public class STSearchArray {
+ private static final int[] GRADES = {94, 96, 100, 97, 94, 100, 93};
+
+ public static void main(String[] args) {
+ // boolean stores flag in case no 100's were found
+ boolean atLeastOne = false;
+ // loops through grades, checking if each one is equal to 100
+ for (int i = 0; i < GRADES.length; i++) {
+ // if the grade equals 100, it displays which grade it is (using the getPlace method)
+ // then it displays which subscript it's in
+ // finally it sets the atLeastOne flag to true so the sorry messages does not get displayed
+ if (GRADES[i] == 100) {
+ System.out.println("Your " + getPlace(i + 1) + " grade (subscript " + i + ") is a 100%, good job!");
+ atLeastOne = true;
+ }
+ }
+ // if the atLeastOne flag is false, the sorry message will be displayed
+ if (!atLeastOne) {
+ System.out.println("Sorry, but you did not score 100% on anything :(");
+ }
+ }
+
+
+ /**
+ * I bashed my head against my keyboard until this method worked properly...
+ *
+ * This method takes a number and determines if it gets suffixed with 'st', 'nd', 'rd', or 'th'
+ * @param index number you want suffixed with 'st', 'nd', 'rd', or 'th'
+ * @return String value of # and 'st', 'nd', 'rd', or 'th'
+ */
+ private static String getPlace(int index) {
+ // Separate number into individual digits (chars)
+ char[] digits = String.valueOf(index).toCharArray();
+ // Quick 'th' suffix for non-edge cases
+ String nonSpecial = Integer.parseInt(String.valueOf(digits)) + "th";
+ // Catches stupid 11th 12th and 13th cases
+ // Ensures number is > 9
+ if (digits.length > 1) {
+ // Ensures the tens place is 1
+ if (digits[digits.length - 2] == '1') {
+ return nonSpecial;
+ }
+ }
+ // Quick ternary operation to quickly deal with single digits
+ // This String will have 1st, 2nd, or 3rd appended if necessary
+ // Otherwise the switch case will return the precalculated value
+ final String podiumCasesPrefix = digits.length > 1 ?
+ String.valueOf(digits).substring(0, digits.length - 1) :
+ "";
+ // Switch case for adding the special 'st', 'nd', and 'rd' suffixes
+ // Or returning the initial 'th' ending
+ switch (digits[digits.length - 1]) {
+ case '1' -> {
+ return podiumCasesPrefix + "1st";
+ }
+ case '2' -> {
+ return podiumCasesPrefix + "2nd";
+ }
+ case '3' -> {
+ return podiumCasesPrefix + "3rd";
+ }
+ default -> {
+ return nonSpecial;
+ }
+ }
+ }
+}
diff --git a/src/main/java/tech/nevets/STSecretMessage.java b/src/main/java/tech/nevets/STSecretMessage.java
new file mode 100644
index 0000000..2a2d454
--- /dev/null
+++ b/src/main/java/tech/nevets/STSecretMessage.java
@@ -0,0 +1,49 @@
+package tech.nevets;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.StringTokenizer;
+
+/**
+ * This class will extract a secret word from the string in the secret.txt file.
+ * Ensure you have created a secret.txt file, with text, in the same directory as the program.
+ */
+public class STSecretMessage {
+ /**
+ * Main method where everything takes place
+ * @param args default args variable
+ * @throws FileNotFoundException FileReader will error out if the secret.txt file does not exist.
+ */
+ public static void main(String[] args) throws FileNotFoundException {
+ // The following 4 lines opens a buffered reader from a file reader
+ // Then it creates the string by appending all the lines into a single StringBuilder
+ // To achieve this, I used Java's built-in Streams API
+ BufferedReader reader = new BufferedReader(new FileReader("./secret.txt"));
+ StringBuilder sb = new StringBuilder();
+ reader.lines().forEach(sb::append);
+ String secretTextRaw = sb.toString();
+
+ // Below loops through the StringTokenizer object while counting each fifth interval
+ StringTokenizer tokenizer = new StringTokenizer(secretTextRaw, " ", false);
+ StringBuilder secret = new StringBuilder();
+ // Here we set the counter to 4 to start with the first word in the secret text.
+ int count = 4;
+ // I initialize the String variable with the first token
+ // For the boolean check I make sure there are still tokens left in the buffer, preventing an exception.
+ // Finally, I update the String variable with the next token.
+ for (String s = tokenizer.nextToken(); tokenizer.countTokens() > 0; s = tokenizer.nextToken()) {
+ // On the fifth interval it will append the first char of the token to the secret StringBuilder
+ // Then reset the counter
+ if (count == 4) {
+ secret.append(s.charAt(0));
+ count = 0;
+ // On the off intervals, it increments the counter and loops again.
+ } else {
+ count++;
+ }
+ }
+ // This line converts the StringBuilder to a string, then turns it to all caps and writes it to the console.
+ System.out.println(secret.toString().toUpperCase());
+ }
+}