From 9e2bd0135df3662da4d80587eb6b6f3f6258a9ec Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Thu, 17 Dec 2020 15:45:12 -0600 Subject: [PATCH 01/11] annotations lesson started --- src/AnnotationsLec/AnnotationsLecture.java | 64 ++++++++++++++++++++++ src/AnnotationsLec/Child.java | 20 +++++++ src/AnnotationsLec/Parent.java | 17 ++++++ src/grades/GradesApplication.java | 63 +++++++++++---------- txt/annotations.txt | 0 5 files changed, 135 insertions(+), 29 deletions(-) create mode 100644 src/AnnotationsLec/AnnotationsLecture.java create mode 100644 src/AnnotationsLec/Child.java create mode 100644 src/AnnotationsLec/Parent.java create mode 100644 txt/annotations.txt diff --git a/src/AnnotationsLec/AnnotationsLecture.java b/src/AnnotationsLec/AnnotationsLecture.java new file mode 100644 index 0000000..ecdb107 --- /dev/null +++ b/src/AnnotationsLec/AnnotationsLecture.java @@ -0,0 +1,64 @@ +package annotationsLecture; + +import java.util.ArrayList; +import java.util.List; + +public class AnnotationsLecture { + public static int someNum = 3; + + public static void main(String[] args) { + +// https://javarevisited.blogspot.com/2015/09/what-is-suppresswarnings-annotation-in-java-unchecked-raw-serial.html#axzz6goBrQ6Sy + + Child child1 = new Child(); + + //TODO TOGETHER: Call deprecated method & no comment + //TODO TOGETHER: Call deprecated method with comment +// child1.sayHello(); + + + + + //TODO TOGETHER:Call sayHello without @Override + //TODO TOGETHER: Comment out annotation and change Parent sayHello no sayHelloParent (Notice there is no error!) +// child1.deprecatedMethod(); + + +// doRiskyThings(); + + } + + //TODO Together: explore analyze > inspect code + + + + //TODO Together: Use @SuppressWarnings +// @SuppressWarnings("deprecation rawtypes unused unchecked") +// @SuppressWarnings("all") + public static void doRiskyThings(){ + Child riskyChild = new Child(); + riskyChild.oldMethod(); //static access & deprecation + + List l = new ArrayList(); // raw use warning + l.add("test"); // unchecked warning + int three = 3; // unused warning + + System.out.println(l); + AnnotationsLecture al = new AnnotationsLecture(); + System.out.println(al.someNum); // static-access warning + + String someName = "Fred"; // unused + + + // Notice these warnings are still present! + if (true) { + ; + } + + Boolean test = true; // + if (test) { + System.out.println("TRUE!"); + } + } + +} \ No newline at end of file diff --git a/src/AnnotationsLec/Child.java b/src/AnnotationsLec/Child.java new file mode 100644 index 0000000..ada5cf8 --- /dev/null +++ b/src/AnnotationsLec/Child.java @@ -0,0 +1,20 @@ +package annotationsLecture; + +public class Child extends Parent { + @Override + public void sayHello(){ + System.out.println("Hello from child class!"); + } + + /** + * @deprecated Use newMethod instead {@link #imAMethod()} + */ + @Deprecated + public void deprecatedMethod(){ + System.out.println("I'm a deprecated method!"); + } + + public void imAMethod(){ + System.out.println("I'm a method!"); + } +} diff --git a/src/AnnotationsLec/Parent.java b/src/AnnotationsLec/Parent.java new file mode 100644 index 0000000..8c67a42 --- /dev/null +++ b/src/AnnotationsLec/Parent.java @@ -0,0 +1,17 @@ +package annotationsLecture; + +public class Parent { + public void sayHello(){ + System.out.println("Hello from parent class!"); + } + + @Deprecated + public static void oldMethod() { + System.out.println("Old way of doing things..."); + } + + public static void newMethod() { + System.out.println("New way of doing things..."); + } + +} diff --git a/src/grades/GradesApplication.java b/src/grades/GradesApplication.java index 3d3001c..22418b6 100644 --- a/src/grades/GradesApplication.java +++ b/src/grades/GradesApplication.java @@ -3,6 +3,7 @@ import util.Input; import java.util.HashMap; +import java.util.Map; public class GradesApplication extends Student { @@ -14,6 +15,38 @@ public GradesApplication(String name) { public static void main(String[] args) { + Map students = getStudents(); + boolean accessGrades = true; + Input userInput = new Input(); + + do { + System.out.println("Here are the GitHub usernames of our students:"); + for (String username : students.keySet()) { + System.out.printf(" |%s| ", username); + } + // new line for separating string from question + System.out.println(); + + String usernameChoice = userInput.getString("What student would you like to see more information on?"); + + if(!students.containsKey(usernameChoice)) { + System.out.printf("Sorry, no student found with the GitHub username of \"%s\".\n", usernameChoice); + } else { + System.out.println("********************"); + System.out.printf("Name: %s - GitHub Username: %s\n", students.get(usernameChoice).getName(), usernameChoice); + System.out.printf("Current Average: %.2f\n", students.get(usernameChoice).getGradeAverage()); + } + Input userInput1 = new Input(); + accessGrades = userInput1.yesNo("Do you want to continue?"); + } while(accessGrades); + System.out.println("Goodbye, and have a wonderful day!"); + + + } + + public static Map getStudents() { + Map students = new HashMap<>(); + Student s1 = new Student("Kristen"); s1.addGrade(95); s1.addGrade(96); @@ -42,35 +75,7 @@ public static void main(String[] args) { s4.addGrade(94); students.put("bobert", s4); - - - - boolean accessGrades = true; - Input userInput = new Input(); - - do { - System.out.println("Here are the GitHub usernames of our students:"); - for (String username : students.keySet()) { - System.out.printf(" |%s| ", username); - } - // new line for separating string from question - System.out.println(); - - String usernameChoice = userInput.getString("What student would you like to see more information on?"); - - if(!students.containsKey(usernameChoice)) { - System.out.printf("Sorry, no student found with the GitHub username of \"%s\".\n", usernameChoice); - } else { - System.out.println("********************"); - System.out.printf("Name: %s - GitHub Username: %s\n", students.get(usernameChoice).getName(), usernameChoice); - System.out.printf("Current Average: %.2f\n", students.get(usernameChoice).getGradeAverage()); - } - Input userInput1 = new Input(); - accessGrades = userInput1.yesNo("Do you want to continue?"); - } while(accessGrades); - System.out.println("Goodbye, and have a wonderful day!"); - - + return students; } } diff --git a/txt/annotations.txt b/txt/annotations.txt new file mode 100644 index 0000000..e69de29 From f50d1a51f36855ed409aad51032a028aed1e9322 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 09:22:22 -0600 Subject: [PATCH 02/11] started exceptions lecture --- src/AnnotationsLec/AnnotationsLecture.java | 8 +- src/AnnotationsLec/Child.java | 2 +- src/AnnotationsLec/Parent.java | 2 +- src/exceptionsLecture/ExceptionsLec.java | 180 +++++++++++++++++++++ txt/exceptions.txt | 20 +++ 5 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 src/exceptionsLecture/ExceptionsLec.java create mode 100644 txt/exceptions.txt diff --git a/src/AnnotationsLec/AnnotationsLecture.java b/src/AnnotationsLec/AnnotationsLecture.java index ecdb107..b1a2792 100644 --- a/src/AnnotationsLec/AnnotationsLecture.java +++ b/src/AnnotationsLec/AnnotationsLecture.java @@ -1,4 +1,4 @@ -package annotationsLecture; +package AnnotationsLec; import java.util.ArrayList; import java.util.List; @@ -14,17 +14,17 @@ public static void main(String[] args) { //TODO TOGETHER: Call deprecated method & no comment //TODO TOGETHER: Call deprecated method with comment -// child1.sayHello(); + child1.sayHello(); //TODO TOGETHER:Call sayHello without @Override //TODO TOGETHER: Comment out annotation and change Parent sayHello no sayHelloParent (Notice there is no error!) -// child1.deprecatedMethod(); + child1.deprecatedMethod(); -// doRiskyThings(); + doRiskyThings(); } diff --git a/src/AnnotationsLec/Child.java b/src/AnnotationsLec/Child.java index ada5cf8..67a1557 100644 --- a/src/AnnotationsLec/Child.java +++ b/src/AnnotationsLec/Child.java @@ -1,4 +1,4 @@ -package annotationsLecture; +package AnnotationsLec; public class Child extends Parent { @Override diff --git a/src/AnnotationsLec/Parent.java b/src/AnnotationsLec/Parent.java index 8c67a42..d18ee87 100644 --- a/src/AnnotationsLec/Parent.java +++ b/src/AnnotationsLec/Parent.java @@ -1,4 +1,4 @@ -package annotationsLecture; +package AnnotationsLec; public class Parent { public void sayHello(){ diff --git a/src/exceptionsLecture/ExceptionsLec.java b/src/exceptionsLecture/ExceptionsLec.java new file mode 100644 index 0000000..22959ba --- /dev/null +++ b/src/exceptionsLecture/ExceptionsLec.java @@ -0,0 +1,180 @@ +package exceptionsLecture; + +import java.util.ArrayList; +import java.util.Scanner; + +public class ExceptionsLec { + public static void main(String[] args) { +// https://stackoverflow.com/questions/18679090/when-to-catch-the-exception-vs-when-to-throw-the-exceptions + + System.out.println("Our program is running."); + + + /* ******************************************************** */ + /* ********************* Try Catch ************************ */ + /* ******************************************************** */ + + +// String[] days = {"Monday", "Tuesday", "Wednesday"}; +// System.out.println(days[4]); //ArrayIndexOutOfBoundsException + + + // TODO: Try/Catch with days array + +// try{ +// //try this code +// String[] days = {"Monday", "Tuesday", "Wednesday"}; +// System.out.println(days[4]); //ArrayIndexOutOfBoundsException +// } catch (ArrayIndexOutOfBoundsException e){ +// //if that code throws an error, catch it here, and do something! +// System.out.println("There is an out of bounds exception with our days array!"); +// e.printStackTrace(System.out); +//// e.printStackTrace(); +// } catch (Exception e){ +// System.out.println("General Exception"); +// e.printStackTrace(); +// } + + + + + + +// int[] numbers = null; +// System.out.println(numbers[0]); //NullPointerException + + + /* + * + * Note that only the most specific catch block executes. + * In the example below, we never reach the catch block for Exception because a more specific catch block was invoked. + * + */ + + //TODO: Try/catch with numbers array +// try { +// int[] numbers = null; +// System.out.println(numbers[0]); +// }catch (NullPointerException e){ +// System.out.println("Null pointer exception"); +// e.printStackTrace(System.out); +// }catch (Exception e){ +// System.out.println("Try again!"); +// e.printStackTrace(System.out); +// } + + + + + + try { +// throw new Exception("Something went wrong"); // Generally wrong - last catch + +// throw new NullPointerException("Something went wrong message"); // Something went wrong message + +// throw new ArrayIndexOutOfBoundsException(); //Runtime exception happened + + + } catch(NullPointerException e) { + System.out.println(e.getMessage()); //This gets the message passed when the exception is thrown + } catch(RuntimeException e) { + System.out.println("Runtime exception happened"); + } catch(Exception e) { + System.out.println("Something went wrong generally"); + } + + + + + + + + /* ******************************************************** */ + /* ********************** Finally Block ******************* */ + /* ******************************************************** */ + +// int[] numbers = {1, 2, 3}; +// int x = 5; +// +// try { +//// x = numbers[1]; +// +// //TODO: Change the index to 5 +// x = numbers[5]; +// +// } catch (ArrayIndexOutOfBoundsException e) { +// System.out.println("Exception caught!"); +// x = 0; +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// System.out.println("This will always run."); +// // normally used for "clean up" like closing file streams or DB connections +// } + +// System.out.println("The value of x: " + x); +// +// +// System.out.println("Yay our code keeps running!"); + + + /* ******************************************************** */ + /* ******************* CALLING A METHOD ******************* */ + /* ******************************************************** */ +// thisHandlesAnException(); + + + + + + + /* ******************************************************** */ + /* *********** TRY/CATCH VS METHOD SIGNATURE ************** */ + /* ******************************************************** */ + +// String indentationPreference; + + +// try { +// indentationPreference = getIndentationPreference(); +// System.out.println("Okay, " + indentationPreference + " is a great choice."); +// } catch (Exception e) { +// System.out.println("Uh oh, something went wrong: " + e.getMessage()); +// System.out.println("Here is some more detail:"); +// e.printStackTrace(); +// } + +// String indentationPreference = getIndentationPreference(); +// System.out.println("Okay, " + indentationPreference + " is a great choice."); + } + + + + + + public static void thisHandlesAnException() { + try { + throw new Exception("Yep, an exception again :("); + } catch (Exception e) { + System.out.println("EXCEPTION!!!"); + System.out.println(e.getMessage()); + e.printStackTrace(System.out); + } + } + + + + + + public static String getIndentationPreference() throws Exception { + Scanner sc = new Scanner(System.in); + System.out.print("What type of indentation do you prefer?"); + String indentationPreference = sc.nextLine(); + + if (indentationPreference.equals("tabs")) { + throw new Exception("Spaces are superior!"); + } + + return indentationPreference; + } +} \ No newline at end of file diff --git a/txt/exceptions.txt b/txt/exceptions.txt new file mode 100644 index 0000000..d40e4b1 --- /dev/null +++ b/txt/exceptions.txt @@ -0,0 +1,20 @@ +EXCEPTIONS + +- a tool to handle errors +- built-in exception class = and object with the type Exception +- usually a message that describes what went wrong + +"exceptions are thrown" when an application can't perform an action + +Trying to access an index that is out of bounds +--ArrayIndexOutOfBounds + +Try-Catch +- use this to manage the crashing of an application +- control flow structure +- catch blocks go from more to less specific +- the most specific catch block will execute +- block scope - cannot access the variables inside the try-catch from the outside + +Try +- the code here will be tried, but it could cause an exception \ No newline at end of file From c1289868316db0a299fbc0727de3c38e8458f87a Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 10:44:23 -0600 Subject: [PATCH 03/11] exercise and part of bonsues --- src/exceptionsLecture/ExceptionsLec.java | 26 ++++----- src/util/Input.java | 74 +++++++++++++++++++++--- src/util/InputTest.java | 18 +++--- txt/exceptions.txt | 42 +++++++++++++- 4 files changed, 129 insertions(+), 31 deletions(-) diff --git a/src/exceptionsLecture/ExceptionsLec.java b/src/exceptionsLecture/ExceptionsLec.java index 22959ba..fbec859 100644 --- a/src/exceptionsLecture/ExceptionsLec.java +++ b/src/exceptionsLecture/ExceptionsLec.java @@ -21,20 +21,20 @@ public static void main(String[] args) { // TODO: Try/Catch with days array -// try{ -// //try this code -// String[] days = {"Monday", "Tuesday", "Wednesday"}; -// System.out.println(days[4]); //ArrayIndexOutOfBoundsException -// } catch (ArrayIndexOutOfBoundsException e){ -// //if that code throws an error, catch it here, and do something! -// System.out.println("There is an out of bounds exception with our days array!"); -// e.printStackTrace(System.out); -//// e.printStackTrace(); -// } catch (Exception e){ -// System.out.println("General Exception"); + try{ + //try this code + String[] days = {"Monday", "Tuesday", "Wednesday"}; + System.out.println(days[4]); //ArrayIndexOutOfBoundsException + } catch (ArrayIndexOutOfBoundsException e){ + //if that code throws an error, catch it here, and do something! + System.out.println("There is an out of bounds exception with our days array!"); + e.printStackTrace(System.out); // e.printStackTrace(); -// } - + } catch (Exception e){ + System.out.println("General Exception"); + e.printStackTrace(); + } + // can use the general when we're not sure about which error will happen diff --git a/src/util/Input.java b/src/util/Input.java index 0596dec..3602752 100644 --- a/src/util/Input.java +++ b/src/util/Input.java @@ -1,5 +1,7 @@ package util; -import org.w3c.dom.ls.LSOutput; + +import static java.lang.Double.parseDouble; +import static java.lang.Integer.parseInt; import java.util.Scanner; @@ -14,7 +16,8 @@ public Input () { } public String getString() { - System.out.println("Please enter a string:"); +// System.out.println("Please enter a string:"); + // adding extra line of text to binary and hex functions return this.myScanner.nextLine(); } public String getString(String prompt) { @@ -54,8 +57,13 @@ public boolean yesNo(String prompt) { // return userInput; // } - public int getInt(int min, int max, String prompt) { - return getInt(min, max, "Please enter an int between" + min + " and " + max); + public int getInt(String prompt) { + System.out.println(prompt); + return getInt(); + } + +// public int getInt(int min, int max, String prompt) { +// return getInt(min, max, "Please enter an int between" + min + " and " + max); // int input; // do{ // System.out.printf("Please enter an int between %d and %d.", min, max); @@ -63,11 +71,17 @@ public int getInt(int min, int max, String prompt) { // }while(input < min || input > max); // // return input; - } +// } public int getInt () { - System.out.println("please enter an integer"); - return this.myScanner.nextInt(); + try { + System.out.println("Working!"); + return Integer.parseInt(getString()); + } catch (NumberFormatException e) { + System.out.println(e.toString()); +// e.printStackTrace(System.out); + return getInt("Please enter an integer"); + } } // public double getDouble(double min, double max) { @@ -80,6 +94,12 @@ public int getInt () { // return getDouble(min, max); // } // } + + public double getDouble(String prompt) { + System.out.println(prompt); + return getDouble(); + } + public double getDouble(double min, double max) { double input; do{ @@ -91,8 +111,44 @@ public double getDouble(double min, double max) { } public double getDouble() { - System.out.println("please enter a double:"); - return myScanner.nextDouble(); + try { +// System.out.println("Working!"); + return Double.parseDouble(getString()); + // putting valueOf here will cause intellij to ask if you want to use parseDouble instead + } catch (RuntimeException e) { + System.out.println(e.toString()); + e.printStackTrace(); + return getDouble("Please enter a double (number with decimals)."); + } + } + + public int getBinary() { + System.out.println("Please enter a number."); + try { +// System.out.println("Working!"); + return Integer.parseInt(getString(), 2); + // valueOf doesn't work in this specific setup, need to figure that out + } catch (NumberFormatException e) { + System.out.println(e.toString()); + System.out.println("Please re-enter a number."); + e.printStackTrace(); + return getBinary(); + } } + + public int getHex() { + System.out.println("Please enter a number."); + try { +// System.out.println("Working!"); + return Integer.parseInt(getString(), 16); + // valueOf doesn't work in this specific setup, need to figure that out + } catch (NumberFormatException e) { + System.out.println(e.toString()); + System.out.println("Please re-enter a number."); + e.printStackTrace(); + return getHex(); + } + } } + diff --git a/src/util/InputTest.java b/src/util/InputTest.java index 64ce396..2c045db 100644 --- a/src/util/InputTest.java +++ b/src/util/InputTest.java @@ -9,18 +9,20 @@ public static void main(String[] args) { Input input = new Input(); // System.out.println("please enter a string:"); - String userString = input.getString(); - System.out.println(userString); +// String userString = input.getString(); +// System.out.println(userString); // System.out.println("please enter a value to test for true/false:"); - Boolean userBoolean = input.yesNo(); - System.out.println(userBoolean); - System.out.println(input.getInt(1, 10, "hello")); +// Boolean userBoolean = input.yesNo(); +// System.out.println(userBoolean); + System.out.println(input.getInt("Enter an integer:")); +// System.out.println(input.getInt(1, 10, "hello")); // System.out.println("please enter a value to test if entry is valid integer:"); // input.getInt(); - System.out.println(input.getDouble(1.0, 50.0)); - - + System.out.println(input.getDouble("Enter a floating number (number with decimals):")); +// System.out.println(input.getDouble(1.0, 50.0)); + System.out.println(input.getBinary()); + System.out.println(input.getHex()); } } diff --git a/txt/exceptions.txt b/txt/exceptions.txt index d40e4b1..c814eac 100644 --- a/txt/exceptions.txt +++ b/txt/exceptions.txt @@ -17,4 +17,44 @@ Try-Catch - block scope - cannot access the variables inside the try-catch from the outside Try -- the code here will be tried, but it could cause an exception \ No newline at end of file +- the code here will be tried, but it could cause an exception + +Catch +- code that handles any exceptions +- We almost always use e the identifier in the catch block + +Exception Methods +--getMessage - returns the exception message as a string +-printStackTrace - prints results into the console for us (where the exception occurred) + +Types of Exceptions +- Unchecked Exceptions + --Mostly exceptions that are built in Java + --Do not need to be explicitly dealth with + --"compiler doesn't really care about them" +- Checked Exceptions + --MUST be dealt with! + --if you have a checked exceptions in your code, your code will not run + --Use a try/catch + --or by using a method signature + --adding a 'throws Exception' into the psvm + --won't have as much control if a certain exception is thrown + --enforced by the compiler (if not handled, the code will not run) +- Error + --out of scope for now + --errors represent something being very wrong + --OutOfMemoryError + + |-> THROWABLE <-| + EXCEPTION(CHECKED) | ERROR(UNCHECKED) + ^ | ^ + RuntimeException(Unchecked) | OutOfMemoryError + ^ | ^ | + NullPointerException | IOException | + MyCustomException| + +- printStackTrace can be anywhere in console, not always where we think it should be + + + + From c9141c8bcbbc0b14594f77212c293155faf5286f Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 12:20:18 -0600 Subject: [PATCH 04/11] fileIO lecture --- data/day18.txt | 379 +++++++++++++++++++++++++++++++ src/fileIo/FileReader.java | 11 + src/fileIo/FileReaderBackup.java | 169 ++++++++++++++ src/fileIo/README.md | 25 ++ src/fileIo/jolts.txt | 107 +++++++++ 5 files changed, 691 insertions(+) create mode 100644 data/day18.txt create mode 100644 src/fileIo/FileReader.java create mode 100644 src/fileIo/FileReaderBackup.java create mode 100644 src/fileIo/README.md create mode 100644 src/fileIo/jolts.txt diff --git a/data/day18.txt b/data/day18.txt new file mode 100644 index 0000000..9e505d4 --- /dev/null +++ b/data/day18.txt @@ -0,0 +1,379 @@ +((5 + 8 + 3) + 3) + (3 + 9 * 7) +((5 + 3) * 9 * (9 * 6 + 6 * 4) + (5 + 5)) * 8 * 9 +(7 + (6 * 3 + 6 * 4 * 9 + 3) * 4 + 6 + 8) + ((5 + 6 + 5 * 3 * 3) * (6 * 8 * 8 * 5 + 4)) * 7 + 9 * 6 +3 * 6 * 3 * 8 + (4 * 6 + 8 * (8 * 4 * 6 + 4) + (4 * 3 + 4 + 8 + 8 * 9) * 8) + 3 +6 * 4 + (9 * 9 + 5) + 5 * 4 + 9 +7 + 4 + 4 + 5 + (2 + (9 * 3 * 2) * 6) + 9 +2 + 4 + (2 * 9) + 3 * 9 + 9 +9 + ((6 + 2 * 3 * 2) + 7 + 7 * (7 * 9 * 5 * 9) + 3) * 6 +9 * 7 + 4 * 5 * ((7 * 6) * 3 + 4) * (4 * 2 + 7 * 2 + (7 * 8 * 9 * 8) + 2) +3 + 8 + ((2 * 7) * 5 * 2 + (5 * 7 + 9 * 8 * 2)) +(8 * 6) * 4 + 4 + 5 * 9 * (5 + 4 + 4 + 9 * 6) +8 * (9 + (6 * 7 * 2 * 5) + 7) + 3 +2 * 5 * 8 +5 + 2 + 6 * 5 * (3 * 4 + 7 + 2 * 2 * 3) +7 * 8 + 6 * 6 +(7 * 3 + 8 + (7 + 2 * 4 * 2 + 2 * 9) * (4 * 7 + 9 * 8) * 7) * 8 + (6 + 2 * 3 + 6 * 4) + (6 + 9) + 8 * 3 +(2 * 5 + 7 + (5 * 4 * 7 * 6) + (9 * 8 + 9 * 9 * 6)) + 8 + (8 + 5) * 8 + 6 + 8 +6 + (9 + 3 * 5) + 5 +(8 * (3 * 3 * 5 + 6 * 8) + 6 * 8) + 5 +2 + 8 + 3 * (3 + 5) * (5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* 7 * 7 * 7)) * 7 + 9 + 3 +4 + (2 * 5 * 9) +6 + (6 * 2 + (2 * 2 * 2 + 8 + 3) + 5) + 7 + (2 + 3 * (9 + 2 + 5 + 4 + 2 + 3) + 8 * 2 * (9 + 6 + 3)) +6 + 2 + (2 + 7 + 7) + 2 +6 + (6 + 6 + 7) * (5 + 8 * (2 * 6 + 6 + 9 * 7) * 5 + 4 + 7) * 7 +4 * 5 + 9 + 7 + ((6 * 3) + 3 * 2 + 6 * 3 * 8) * (3 + 8 * (7 * 7 * 9 * 2 * 8) * (8 + 2 + 7 + 8 + 9) + (5 * 9 * 6 + 5 * 3 + 9)) +5 + (5 + 5) * 5 +7 * (6 + (7 + 8 + 3 * 3) + 9 + 5 * 7) + 8 + 6 +(8 + (3 * 5 + 6 + 5 + 3 * 8)) * 4 +7 * 7 * 9 * (2 * 7 * 2 * 8) * 6 +5 * ((5 + 6) + (9 * 3 + 9)) * 5 + 6 + 6 + (4 + (9 * 3 * 5 + 6) + 5 * 4 * 7) +8 * 6 + (9 * 9 + 2 + 3 * 6 + (8 * 7 + 8 * 2 * 7 + 2)) + 9 +(7 + 2 * (2 + 9) + (3 * 4 * 7) + 7 + 6) + 8 + 4 * (6 * 2) + 4 * (7 + 5) +5 * 9 * 7 * 5 + (6 + 8) +(3 * 7 + 7 * 9 + (8 + 8) + 8) + (5 * 5 * 8 * 2) * 5 * (5 + 9 * 5 + 2 + (5 * 4)) * 9 * (8 * 2 * 7 * 7) +(4 + 7 * 9 + 5) + ((6 + 3 + 8 + 7) * 6 * 6 + 4 + 5) * 4 * 7 + (4 + 4 + (6 * 2 * 5 + 3)) +2 + 9 * 4 * 7 * (8 * (4 + 8 + 4) * (5 + 7 + 4) * 3) +(3 + 3 + 3 * 8) * 8 * ((3 + 9) + 9 * 2 * 3 + 9) * (5 + 8) + (9 * 2) + 9 +4 + 5 * ((7 * 3 + 6 * 9) * 9) + (5 * 9) * 3 +5 * 5 + (5 * 7 * (5 + 9) + 4) +7 * (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3 * 4 + 2) + 5) + 2 + 7 + 8 +(6 * 3 * 5) * 9 + (6 * 3 * 8) +((2 * 5 + 4 * 6 + 2 * 6) * 7 * 5) * 6 * 9 * 2 +7 * 3 * ((5 * 5 * 4 + 5 * 8 + 4) * 9 * 4 + 7 + (3 + 6 * 2 * 6 + 4) + 3) + 7 + 9 +7 * 6 * (6 * 9 + 5) + 2 + 7 + (6 + 3) +((6 + 2 + 7 + 5 + 7) + 9 * 9) * (4 * (2 + 6 * 7 * 7) * 5) + 9 * 9 * (8 * 6 + 2) +6 + 4 * 7 * (9 * 5 * 6 * 2 + 6) + 8 * 4 +4 * 5 * 9 + ((8 + 3 + 7) + 2 + 5) + 8 +7 * 4 * (7 + 8 * (6 * 7) * 9 * 7 * 6) +2 + 4 + 3 +(7 + 8 * 2) + 2 + (2 * 9 + 6) + 4 * 5 * (2 * 4) +(8 * 8) * 2 + 5 + 7 +7 + (8 + 8 * 6 * 8) + 2 * 7 * 7 * 3 +4 * (9 * 5 + 9) * 3 * 7 +9 + 7 + 9 + 6 + (9 * 9 + 6 + 9) +(9 * 3 * 6) * 7 +2 + (2 + (4 * 2 * 7 + 6) * 7 * 9 * 9 * 9) * 6 + 3 + (3 + 8 * 8 * 7) * 2 +8 + 4 + 6 +7 * (2 * 2 * (8 + 3 + 8) * (3 + 6 * 8 * 3) * 9 + (9 + 9)) * (3 + 5 * 9) +((5 + 9 * 7) * (3 + 9 * 5) * 7 * 4 * 4 * 6) * 9 * 9 + 5 + 9 + 2 +(5 + 6 + (5 + 9) + 7 + 4 * 3) + 2 * (9 + 8 * 5 * 8 * 9) + 8 * (5 * 2 + 6) * 3 +8 + (6 * (3 * 7 + 8 + 8 * 7)) \ No newline at end of file diff --git a/src/fileIo/FileReader.java b/src/fileIo/FileReader.java new file mode 100644 index 0000000..e75da06 --- /dev/null +++ b/src/fileIo/FileReader.java @@ -0,0 +1,11 @@ +package fileIo; + +public class FileReader { + + // properties for this class + // goal: read in a file and parse through it + private String directoryName; // i.e. 'data', 'src/fileIo' + private String fileName; // i.s. 'day18.txt', 'jolts.txt' + + +} \ No newline at end of file diff --git a/src/fileIo/FileReaderBackup.java b/src/fileIo/FileReaderBackup.java new file mode 100644 index 0000000..045e5e8 --- /dev/null +++ b/src/fileIo/FileReaderBackup.java @@ -0,0 +1,169 @@ +//package fileIo; +// +//import java.io.File; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Path; +//import java.nio.file.Paths; +//import java.nio.file.StandardOpenOption; +//import java.util.Arrays; +//import java.util.List; +// +//public class FileReader { +// +// // properties for this class +// // read in the file and parse it +// private String directoryName; // i.e. 'data', 'src/fileIo', etc +// private String fileName; // i.e. 'day18.txt', 'jolts.txt', etc +// private String logFileName; // will hold logging info +// private Path directoryPath; // Path representation for 'data', 'src/fileIo', etc +// private Path filePath; // Path representation for 'data/day18.txt', 'src/fileIo/jolts.txt', etc +// private List fileLines; // A list to iterate through with each line of the file +// private List logLines; // A String list to hold all of the logging messages +// private Path logFilePath; // Path representation of the logging file +// +// +// // Constructor +// public FileReader(String directoryName, String fileName, String logFileName) throws IOException { +// this.directoryName = directoryName; +// this.fileName = fileName; +// this.logFileName = logFileName; +// this.directoryPath = Paths.get(directoryName); +// this.filePath = Paths.get(directoryName, fileName); +// this.logFilePath = Paths.get(directoryName, logFileName); +// +// // Create a logging file if it doesn't already exist +// if (Files.notExists(this.logFilePath)) { +// try { +// Files.createFile(this.logFilePath); +// } catch (IOException e) { +// // if there is an issue creating the log file, let's just crash the whole party +// // because we want to be able to log all errors +// throw new IOException("Unable to create the logfile (" + this.logFileName + ")!"); +// } +// } +// +// // Check to see if the directory path even exists +// // create it, if it doesn't exist +// if (Files.notExists(this.directoryPath)) { +// try { +// Files.createDirectories(this.directoryPath); // createDirectory (only creates the single directory) vs createDirectories (creates non-existent parent directories if necessary) +// } catch (IOException e) { +// // Add the error message to the log +// // this.logLines.add(e.getMessage()); +// Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); +// throw new IOException("Unable to create the data directory (" + this.directoryName + ")!"); +// // stop all execution so we can investigate what went wrong +// } +// } +// +// // Check to see if the file path even exists +// // create it, if it doesn't exist +// if (Files.notExists(this.filePath)) { +// try { +// Files.createFile(this.filePath); +// } catch (IOException e) { +// // Add the error message to the log +// // this.logLines.add(e.getMessage()); +// Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); +// throw new IOException("Unable to create the data file (" + this.fileName + ")!"); +// // stop all execution so we can investigate what went wrong +// } +// } +// +// // Take a look at the actual filePath value as a string +// System.out.println(this.filePath.toString()); +// this.fileLines = Files.readAllLines(this.filePath); // populate the fileLines String array +// } +// +// public static void main(String[] args) throws IOException { +// FileReader adventDayEighteen = new FileReader("data", "day18.txt", "day18_log.txt"); +// FileReader jolts = new FileReader("src/fileIo", "jolts.txt", "jolts_log.txt"); +// +// adventDayEighteen.writeToLog("Initialized file reader"); +// jolts.writeToLog("Initialized file reader"); +// +// System.out.println(adventDayEighteen.getFileLines().get(0)); +// System.out.println(jolts.getFileLines().get(0)); +// +// adventDayEighteen.writeToLog("Retrieved first line of all data file lines."); +// jolts.writeToLog("Retrieved first line of all data file lines."); +// } +// +// // Custom message to easily write to the log whenever we want to! +// public void writeToLog(String message) throws IOException { +// try { +// Files.write(this.getLogFilePath(), Arrays.asList(message), StandardOpenOption.APPEND); +// } catch(IOException e) { +// // store the exception message in our log file +// Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); +// throw new IOException("Unable to write exception message to log file!"); +// } +// } +// +// // Getters & Setters +// public String getDirectoryName() { +// return directoryName; +// } +// +// public void setDirectoryName(String directoryName) { +// this.directoryName = directoryName; +// } +// +// public String getFileName() { +// return fileName; +// } +// +// public void setFileName(String fileName) { +// this.fileName = fileName; +// } +// +// public String getLogFileName() { +// return logFileName; +// } +// +// public void setLogFileName(String logFileName) { +// this.logFileName = logFileName; +// } +// +// public Path getDirectoryPath() { +// return directoryPath; +// } +// +// public void setDirectoryPath(Path directoryPath) { +// this.directoryPath = directoryPath; +// } +// +// public Path getFilePath() { +// return filePath; +// } +// +// public void setFilePath(Path filePath) { +// this.filePath = filePath; +// } +// +// public List getFileLines() { +// return fileLines; +// } +// +// public void setFileLines(List fileLines) { +// this.fileLines = fileLines; +// } +// +// public List getLogLines() { +// return logLines; +// } +// +// public void setLogLines(List logLines) { +// this.logLines = logLines; +// } +// +// public Path getLogFilePath() { +// return logFilePath; +// } +// +// public void setLogFilePath(Path logFilePath) { +// this.logFilePath = logFilePath; +// } +//} \ No newline at end of file diff --git a/src/fileIo/README.md b/src/fileIo/README.md new file mode 100644 index 0000000..9f66b98 --- /dev/null +++ b/src/fileIo/README.md @@ -0,0 +1,25 @@ +# Order of FileReader Class Creation + +### Paths +1. Create a **directory** string property +1. Create a **filename** string property +1. Create a **logfileName** string property +1. Initialize the path for our file + +### Getters and Setters +1. We can use the IntelliJ shortcut to create these + +### Constructor +We'll be using the following methods in our constructor +1. **Paths**.get +1. **Files**.notExists +1. **Files**.createFile +1. **Files**.createDirectories +1. **Files**.write +1. **Files**.readAllLines + +### Special Logging Method +I also want a method that will log any string I send in to the log file. + +### Test it all out (PSVM) +Finally, just need to test it all out with a `public static void main() { ...` \ No newline at end of file diff --git a/src/fileIo/jolts.txt b/src/fileIo/jolts.txt new file mode 100644 index 0000000..49e3083 --- /dev/null +++ b/src/fileIo/jolts.txt @@ -0,0 +1,107 @@ +105 +124 +42 +52 +71 +41 +1 +85 +148 +90 +155 +112 +35 +134 +145 +39 +161 +160 +34 +54 +15 +165 +8 +20 +46 +49 +108 +151 +60 +7 +48 +154 +63 +147 +132 +98 +158 +33 +137 +45 +140 +121 +22 +62 +111 +141 +167 +131 +74 +93 +2 +142 +113 +21 +162 +61 +3 +19 +101 +9 +102 +115 +70 +12 +84 +6 +114 +107 +97 +133 +64 +80 +78 +91 +79 +14 +168 +87 +159 +30 +94 +77 +40 +125 +47 +27 +38 +166 +86 +26 +23 +67 +127 +28 +16 +169 +13 +92 +106 +57 +118 +126 +83 +146 +29 +130 +53 \ No newline at end of file From 62a03cf1a2f3f8bd561ca66d7997318b40c89c67 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 13:33:28 -0600 Subject: [PATCH 05/11] lesson updates --- src/fileIo/FileReader.java | 89 +++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/src/fileIo/FileReader.java b/src/fileIo/FileReader.java index e75da06..1feb0b0 100644 --- a/src/fileIo/FileReader.java +++ b/src/fileIo/FileReader.java @@ -1,11 +1,96 @@ package fileIo; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + public class FileReader { // properties for this class // goal: read in a file and parse through it - private String directoryName; // i.e. 'data', 'src/fileIo' - private String fileName; // i.s. 'day18.txt', 'jolts.txt' + private String directoryName; // i.e. 'data', 'src/fileIo' + private String fileName; // i.s. 'day18.txt', 'jolts.txt' + private String logFileName; // will hold logging info + private Path directoryPath; // Path representation of the parent directory for our files + private Path filePath; // Path representation for the actual file itself + private Path logFilePath; // Path representation of the log file + private List fileLines; // Holding spot for the content inside of the data file itself + private List logFile; // Holding spot for the content inside of the log file + + public FileReader(String directoryName, String fileName, String logFileName) { + this.directoryName = directoryName; + this.fileName = fileName; + this.logFileName = logFileName; + this.directoryPath = Paths.get(directoryName, fileName); + this.filePath = Paths.get(fileName); + this.logFilePath = Paths.get(logFileName); + + + } + + // Getters and Setters + public String getDirectoryName() { + return directoryName; + } + + public void setDirectoryName(String directoryName) { + this.directoryName = directoryName; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getLogFileName() { + return logFileName; + } + + public void setLogFileName(String logFileName) { + this.logFileName = logFileName; + } + + public Path getDirectoryPath() { + return directoryPath; + } + + public void setDirectoryPath(Path directoryPath) { + this.directoryPath = directoryPath; + } + + public Path getFilePath() { + return filePath; + } + + public void setFilePath(Path filePath) { + this.filePath = filePath; + } + + public Path getLogFilePath() { + return logFilePath; + } + + public void setLogFilePath(Path logFilePath) { + this.logFilePath = logFilePath; + } + + public List getFileLines() { + return fileLines; + } + + public void setFileLines(List fileLines) { + this.fileLines = fileLines; + } + public List getLogFile() { + return logFile; + } + public void setLogFile(List logFile) { + this.logFile = logFile; + } } \ No newline at end of file From 2f4f0fa2cf3a4bc195a71e1bcb8b29992c723e42 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 14:10:02 -0600 Subject: [PATCH 06/11] continued notes --- data/day18.log | 0 src/fileIo/FileReader.java | 61 +++++++++++++++++++++++++++++++++++--- src/fileIo/jolts.log | 0 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 data/day18.log create mode 100644 src/fileIo/jolts.log diff --git a/data/day18.log b/data/day18.log new file mode 100644 index 0000000..e69de29 diff --git a/src/fileIo/FileReader.java b/src/fileIo/FileReader.java index 1feb0b0..584ceb8 100644 --- a/src/fileIo/FileReader.java +++ b/src/fileIo/FileReader.java @@ -1,8 +1,13 @@ package fileIo; +import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class FileReader { @@ -18,13 +23,61 @@ public class FileReader { private List fileLines; // Holding spot for the content inside of the data file itself private List logFile; // Holding spot for the content inside of the log file - public FileReader(String directoryName, String fileName, String logFileName) { + // constructor + // Want to send in a directory path and a file name, logFile name, and generate EVERYTHING from just those two values + public FileReader(String directoryName, String fileName, String logFileName) throws IOException { + // assigning the input to be the value for the corresponding variable above this.directoryName = directoryName; this.fileName = fileName; this.logFileName = logFileName; - this.directoryPath = Paths.get(directoryName, fileName); - this.filePath = Paths.get(fileName); - this.logFilePath = Paths.get(logFileName); + // Instantiating Path values + this.directoryPath = Paths.get(directoryName); + this.filePath = Paths.get(directoryName, fileName); + this.logFilePath = Paths.get(directoryName, logFileName); + + // Check if files exist, and create them if they don't currently exist + // Log File + if(Files.notExists(this.logFilePath)) { + try { + Files.createFile(this.logFilePath); + } catch (IOException e) { + // Store this exception message in the log file + // if there is an issue creating the log file, let's just crash the whole party and throw an IO Exception + throw new IOException("Unable to create the logfile (" + this.logFileName + ")!"); + } + } + // Directory for data file ('data'), ('src/fileIo') + if(Files.notExists(this.directoryPath)) { + try { + Files.createDirectories(this.directoryPath); + } catch (IOException e) { + // Add this error message to the log + // Files.write(Path filePath, List message(s), appendOption + Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); + // can also use: +// List errorMessage = new ArrayList<>(); +// errorMessage.add(e.getMessage()); + // and put errorMessage in for the Arrays.asList... + throw new IOException("Unable to create the data directory (" + this.directoryPath + ")!"); + } + } + // Data file ('day18.txt') + if(Files.notExists(this.fileName)) { + + } + + + // Test if this instantiation worked + System.out.println(filePath); // display the gile path for the passed in arguments + } + + // PSVM - you can think of this as being 20 files away from this file since it's STATIC + public static void main(String[] args) throws IOException { + // Instantiate a FileReader object and see if it works + FileReader thisFileReader = new FileReader("data", "day18.txt", "day18.log"); + // Set up a new instance to access the jolts.txt file + FileReader joltsReader = new FileReader("src/fileIo", "jolts.txt", "jolts.log"); + } diff --git a/src/fileIo/jolts.log b/src/fileIo/jolts.log new file mode 100644 index 0000000..e69de29 From 82a747c2181146d9574a26fd18d6a8a973d4c625 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 14:23:43 -0600 Subject: [PATCH 07/11] continued notes --- src/fileIo/FileReader.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/fileIo/FileReader.java b/src/fileIo/FileReader.java index 584ceb8..ccec7ea 100644 --- a/src/fileIo/FileReader.java +++ b/src/fileIo/FileReader.java @@ -54,34 +54,46 @@ public FileReader(String directoryName, String fileName, String logFileName) thr // Add this error message to the log // Files.write(Path filePath, List message(s), appendOption Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); + // append to the end of the log file // can also use: // List errorMessage = new ArrayList<>(); // errorMessage.add(e.getMessage()); // and put errorMessage in for the Arrays.asList... throw new IOException("Unable to create the data directory (" + this.directoryPath + ")!"); + // stops all execution } } // Data file ('day18.txt') - if(Files.notExists(this.fileName)) { - + if(Files.notExists(this.filePath)) { // i.e. 'src/day18.txt' + // if we've made it to this point (inside the if statement), that means the file does not exist - so let's create it! + try { + Files.createFile(filePath); + } catch(IOException e) { + Files.write(this.filePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); + throw new IOException("Unable to create the file (" + this.filePath + ")!"); + } } - - // Test if this instantiation worked System.out.println(filePath); // display the gile path for the passed in arguments + this.fileLines = Files.readAllLines((this.filePath)); // gives me every line in (i.e. 'day18.txt' as a String, inside of a List } - + // --------------------------------------------------------------------- // PSVM - you can think of this as being 20 files away from this file since it's STATIC public static void main(String[] args) throws IOException { // Instantiate a FileReader object and see if it works - FileReader thisFileReader = new FileReader("data", "day18.txt", "day18.log"); + FileReader day18Reader = new FileReader("data", "day18.txt", "day18.log"); // Set up a new instance to access the jolts.txt file FileReader joltsReader = new FileReader("src/fileIo", "jolts.txt", "jolts.log"); + System.out.println("Day 18 file, here's the first line:"); + System.out.println(day18Reader.getFileLines().get(0)); + System.out.println("Jolts file, here's the first line:"); + System.out.println(joltsReader.getFileLines().get(0)); } + // --------------------------------------------------------------------- // Getters and Setters public String getDirectoryName() { return directoryName; From 1632b37ba867978f267779535ee0ece8ce05c992 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Fri, 18 Dec 2020 14:32:49 -0600 Subject: [PATCH 08/11] finished lesson --- data/day18.log | 1 + src/fileIo/FileReader.java | 19 +++++++++++++++++++ src/fileIo/jolts.log | 1 + 3 files changed, 21 insertions(+) diff --git a/data/day18.log b/data/day18.log index e69de29..ba36e00 100644 --- a/data/day18.log +++ b/data/day18.log @@ -0,0 +1 @@ +Successfully read the day18.txt file! diff --git a/src/fileIo/FileReader.java b/src/fileIo/FileReader.java index ccec7ea..da9b14c 100644 --- a/src/fileIo/FileReader.java +++ b/src/fileIo/FileReader.java @@ -77,6 +77,8 @@ public FileReader(String directoryName, String fileName, String logFileName) thr System.out.println(filePath); // display the gile path for the passed in arguments this.fileLines = Files.readAllLines((this.filePath)); // gives me every line in (i.e. 'day18.txt' as a String, inside of a List } + + // --------------------------------------------------------------------- // PSVM - you can think of this as being 20 files away from this file since it's STATIC public static void main(String[] args) throws IOException { @@ -91,6 +93,23 @@ public static void main(String[] args) throws IOException { System.out.println("Jolts file, here's the first line:"); System.out.println(joltsReader.getFileLines().get(0)); + day18Reader.writeToLog("Successfully read the " + day18Reader.getFileName() + " file!"); + + joltsReader.writeToLog("Successfully read the " + joltsReader.getFileName() + " file!"); + } + + + // --------------------------------------------------------------------- + // Custom Method - want to be able to easily write a message to the log, without some enormous nested function calling nonsense + // reason for adding "throws IOException" --> + public void writeToLog(String message) throws IOException { + try { + // write the string 'message' to the log file of THIS INSTANCE of a FileReader object + Files.write(this.logFilePath, Arrays.asList(message), StandardOpenOption.APPEND); + } catch (IOException e) { + Files.write(this.logFilePath, Arrays.asList(e.getMessage()), StandardOpenOption.APPEND); + throw new IOException("Unable to write custom message to log file."); + } } // --------------------------------------------------------------------- diff --git a/src/fileIo/jolts.log b/src/fileIo/jolts.log index e69de29..e349398 100644 --- a/src/fileIo/jolts.log +++ b/src/fileIo/jolts.log @@ -0,0 +1 @@ +Successfully read the jolts.txt file! From 48e64eaff4edf396ad8a0e10fc404844491b0da2 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Sat, 19 Dec 2020 21:27:56 -0600 Subject: [PATCH 09/11] input class update --- src/util/Input.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/Input.java b/src/util/Input.java index 3602752..a44c4bc 100644 --- a/src/util/Input.java +++ b/src/util/Input.java @@ -7,7 +7,7 @@ public class Input { - private final Scanner myScanner; + private Scanner myScanner; // new constructor for scanner public Input () { @@ -18,7 +18,7 @@ public Input () { public String getString() { // System.out.println("Please enter a string:"); // adding extra line of text to binary and hex functions - return this.myScanner.nextLine(); + return myScanner.nextLine(); } public String getString(String prompt) { System.out.println(prompt); @@ -33,9 +33,8 @@ public String getString(String prompt) { // or public boolean yesNo() { - return yesNo("Please enter yes or no:"); -// String userInput = myScanner.next(); -// return userInput.equalsIgnoreCase("yes") || userInput.equalsIgnoreCase("y") || userInput.equalsIgnoreCase("sure"); + String userInput = myScanner.nextLine(); + return userInput.equalsIgnoreCase("yes") || userInput.equalsIgnoreCase("y") || userInput.equalsIgnoreCase("sure"); } @@ -45,6 +44,8 @@ public boolean yesNo(String prompt) { return userInput.equalsIgnoreCase("yes") || userInput.equalsIgnoreCase("y") || userInput.equalsIgnoreCase("sure"); } + + // public int getInt(int min, int max) { // System.out.println("please enter a value to test if valid between %d and %d.\n:"); // int userInput = getInt(); From 74cdf32efb344a7a2184c807ffb8194b26773e29 Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Tue, 22 Dec 2020 23:08:17 -0600 Subject: [PATCH 10/11] extra example --- src/CircleExample.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/CircleExample.java diff --git a/src/CircleExample.java b/src/CircleExample.java new file mode 100644 index 0000000..1f01374 --- /dev/null +++ b/src/CircleExample.java @@ -0,0 +1,40 @@ + +/** + * The Circle class models a circle with a radius and color. + */ +public class CircleExample { // Save as "Circle.java" + // Private instance variables + private double radius; + private String color; + + // Constructors (overloaded) + /** Constructs a Circle instance with default radius and color */ + public CircleExample() { // 1st Constructor (default constructor) + radius = 1.0; + color = "red"; + } + /** Constructs a Circle instance with the given radius and default color*/ + public CircleExample(double r) { // 2nd Constructor + radius = r; + color = "red"; + } + /** Constructs a Circle instance with the given radius and color */ + public CircleExample(double r, String c) { // 3rd Constructor + radius = r; + color = c; + } + + // Public methods + /** Returns the radius */ + public double getRadius() { // getter for radius + return radius; + } + /** Returns the color */ + public String getColor() { // getter for color + return color; + } + /** Returns the area of this circle */ + public double getArea() { + return radius * radius * Math.PI; + } +} \ No newline at end of file From 1a2f5beaf8a9738bba2f637c616e01d829a29d4f Mon Sep 17 00:00:00 2001 From: Kristen Collier Date: Wed, 23 Dec 2020 19:19:23 -0600 Subject: [PATCH 11/11] test class example added --- src/TestCircle.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/TestCircle.java diff --git a/src/TestCircle.java b/src/TestCircle.java new file mode 100644 index 0000000..1680887 --- /dev/null +++ b/src/TestCircle.java @@ -0,0 +1,33 @@ +/** + * A Test Driver for the "Circle" class + */ +public class TestCircle { // Save as "TestCircle.java" + public static void main(String[] args) { // Program entry point + // Declare and Construct an instance of the Circle class called c1 + CircleExample c1 = new CircleExample(2.0, "blue"); // Use 3rd constructor + System.out.println("The radius is: " + c1.getRadius()); // use dot operator to invoke member methods + //The radius is: 2.0 + System.out.println("The color is: " + c1.getColor()); + //The color is: blue + System.out.printf("The area is: %.2f%n", c1.getArea()); + //The area is: 12.57 + + // Declare and Construct another instance of the Circle class called c2 + CircleExample c2 = new CircleExample(2.0); // Use 2nd constructor + System.out.println("The radius is: " + c2.getRadius()); + //The radius is: 2.0 + System.out.println("The color is: " + c2.getColor()); + //The color is: red + System.out.printf("The area is: %.2f%n", c2.getArea()); + //The area is: 12.57 + + // Declare and Construct yet another instance of the Circle class called c3 + CircleExample c3 = new CircleExample(); // Use 1st constructor + System.out.println("The radius is: " + c3.getRadius()); + //The radius is: 1.0 + System.out.println("The color is: " + c3.getColor()); + //The color is: red + System.out.printf("The area is: %.2f%n", c3.getArea()); + //The area is: 3.14 + } +} \ No newline at end of file