From aeb8c6c24f9ff0b032a8bd366d23d4dff6bd56eb Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Wed, 10 Mar 2021 15:30:40 -0500 Subject: [PATCH] Update java class --- cpp/midterm/a.out | Bin 0 -> 17016 bytes cpp/midterm/main.cpp | 39 +++++++++ java/{ => old}/Project/DiceCup.java | 0 java/{ => old}/Project/EightDie.java | 0 java/{ => old}/Project/GameManager.java | 0 java/{ => old}/Project/MyDiceGameTest.java | 0 java/{ => old}/Project/MyDie.java | 0 java/{ => old}/Project/SixDie.java | 0 .../CIS 217 Project 1 Winter 2021(4).docx | Bin .../CIS 217 Project 1 Winter 2021(5).docx | Bin java/{ => old}/Project/notes/notes.java | 0 java/{ => old}/Project/notes/temp-notes.java | 0 .../Project/old-my-dice-game-test.java.old | 0 .../in-class-10-FEB-2021/SmartWatch.java | 0 .../{ => old}/in-class-10-FEB-2021/Watch.java | 0 .../in-class-10-FEB-2021/WatchManager.java | 0 .../plant-information/#Flower.java#} | 0 java/old/plant-information/Flower.java | 33 ++++++++ .../plant-information/GardenManager.java | 0 .../{ => old}/plant-information/MyGarden.java | 0 .../plant-information/MyGardenJUnitTest.java | 0 java/{ => old}/plant-information/Plant.java | 0 .../exceptions-input-file/NamesAndAges.txt | 5 ++ java/week8/exceptions-input-file/main.java | 58 ++++++++++++++ java/week8/lab-string-vs-int/main.java | 74 ++++++++++++++++++ 25 files changed, 209 insertions(+) create mode 100755 cpp/midterm/a.out create mode 100644 cpp/midterm/main.cpp rename java/{ => old}/Project/DiceCup.java (100%) rename java/{ => old}/Project/EightDie.java (100%) rename java/{ => old}/Project/GameManager.java (100%) rename java/{ => old}/Project/MyDiceGameTest.java (100%) rename java/{ => old}/Project/MyDie.java (100%) rename java/{ => old}/Project/SixDie.java (100%) rename java/{ => old}/Project/notes/CIS 217 Project 1 Winter 2021(4).docx (100%) rename java/{ => old}/Project/notes/CIS 217 Project 1 Winter 2021(5).docx (100%) rename java/{ => old}/Project/notes/notes.java (100%) rename java/{ => old}/Project/notes/temp-notes.java (100%) rename java/{ => old}/Project/old-my-dice-game-test.java.old (100%) rename java/{ => old}/in-class-10-FEB-2021/SmartWatch.java (100%) rename java/{ => old}/in-class-10-FEB-2021/Watch.java (100%) rename java/{ => old}/in-class-10-FEB-2021/WatchManager.java (100%) rename java/{plant-information/Flower.java => old/plant-information/#Flower.java#} (100%) create mode 100644 java/old/plant-information/Flower.java rename java/{ => old}/plant-information/GardenManager.java (100%) rename java/{ => old}/plant-information/MyGarden.java (100%) rename java/{ => old}/plant-information/MyGardenJUnitTest.java (100%) rename java/{ => old}/plant-information/Plant.java (100%) create mode 100644 java/week8/exceptions-input-file/NamesAndAges.txt create mode 100644 java/week8/exceptions-input-file/main.java create mode 100644 java/week8/lab-string-vs-int/main.java diff --git a/cpp/midterm/a.out b/cpp/midterm/a.out new file mode 100755 index 0000000000000000000000000000000000000000..67295df3e55b0741a25ed13faab80b0b68969586 GIT binary patch literal 17016 zcmeGjZEzb`@kw$LrD#|P6!{#MV4e+AWI(U zl-i|$8MmFP>4#hRQD6r0hnWo1A7vOIWu~ozL!IgLN6Jh)9zKT9x?n?T(}uL6G!eV+ zcBRuvXsJ9G@L<<@p*%nj$>`qgU@q^Uf zIdlX9^$Xdkcb@dllOAI~=`m)1qEGNTL-l9eDo{wPh(x!%modsB?0dtAW7(@9g;=e? zy^<1wG3$L6^vKmD@$V74eLuBV%P$?&f5zlqu_cupXm8t+inpYa>HJvBSVwzHds`rv z32c?)UJK2mD|hWVAjUmk{c!Hb_rL$tt5ySRqAik68r`koW5Dk-Qn^T<(b^gtj%IZu8%-Ly zNGu%Q54>$4oQ&z2oRLjLM0il-*;E6n!PTz*A~m<4eZ&7*(oRu#bSC6saE92 zxU;dbs2(*EV@U&gjuq7Nk!Uh4cJ)R&yAB=Fw*}hFvc5I2HLx89?S@#uKb(EUIRE%( zKE?`QW7885N*?h$C?jC)PXP0Ckl&DmaC3_VSu4baJ5^c2n6k#-WeeZ>yz%^?EXNue zXry`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P}mNjxl9*&U3L_CpA3?*|$0#aT^^jIpBPUJuO%S;G@wVb+32{QNE_L4F_?{xB=mTGWMmvvER^g@ zg{ZFg><{e@>)}1!n6slpf|MTCh^ck&7kc;S_k?ywx}XlnQBsaqGGx||U=Qu>>FEpi z>;0k5-Y{5A#G^)3=#jmUViQlM^?WW77c$QVMxD#(!_jm+l@NM7rDqeVObpU;Fd4^y z^q4DO1A?K~savU^qIGj6tgzum!h( zY``=I(Pc70-tJy5{466^DNTAmaJ{u~M77}3w%KJTjz0uP&FeO`B~G*I3Tf`|mP zVFg?#;a-gOd41kSKNt-p%>8FM#$SPY+}knD>v)ayRnq4<;{Fp`+ye#dD(mxl|3T8% zNRZoSeIEaPq~A$$ye~LM`ePP-+{4=S9|a!zgzXF758y%_6-CKFF(>61^rW-R*%sR@0Sjdelr@k0M8$@rlA0ofin@T~f<07WtLAORp1%NAfg#&1KNRiD?dYS2`w)jpfN z1O>Fk{hy%r_mMuHhp>WbC7}EPTqr`~rCQd;ZU!6^!0{2fA<^0@i^ iu@ZRPcdLHzR+E~s8RvFcc6AN?i#tpSk4?cwihluOWhGz$ literal 0 HcmV?d00001 diff --git a/cpp/midterm/main.cpp b/cpp/midterm/main.cpp new file mode 100644 index 0000000..e0b2dcf --- /dev/null +++ b/cpp/midterm/main.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; + +int main() { + int num; + int curr; + int i; + int sum, currValue, x; +// string input; + // string input2; + //cin >> input; + //getline(cin,input2); + //getline(cin,input2); + //cout << input << " " << input2 << endl; + +// for (int i=0; i < 100; i++){ +// cout << i + 1 << endl; +// } +//cin >> num; +//for (i = 0; i < num; ++i) { +// cin >> curr; +// cout << curr; +//} +//cin >> x; +/*sum = 0; +for (i = 0; i < x; ++i) { + cin >> currValue; + sum += currValue; +} +cout << sum << endl; +*/ + + x = 18; + while (x>0){ + cout << x << " "; + x = x/3; + } + return 0; +} diff --git a/java/Project/DiceCup.java b/java/old/Project/DiceCup.java similarity index 100% rename from java/Project/DiceCup.java rename to java/old/Project/DiceCup.java diff --git a/java/Project/EightDie.java b/java/old/Project/EightDie.java similarity index 100% rename from java/Project/EightDie.java rename to java/old/Project/EightDie.java diff --git a/java/Project/GameManager.java b/java/old/Project/GameManager.java similarity index 100% rename from java/Project/GameManager.java rename to java/old/Project/GameManager.java diff --git a/java/Project/MyDiceGameTest.java b/java/old/Project/MyDiceGameTest.java similarity index 100% rename from java/Project/MyDiceGameTest.java rename to java/old/Project/MyDiceGameTest.java diff --git a/java/Project/MyDie.java b/java/old/Project/MyDie.java similarity index 100% rename from java/Project/MyDie.java rename to java/old/Project/MyDie.java diff --git a/java/Project/SixDie.java b/java/old/Project/SixDie.java similarity index 100% rename from java/Project/SixDie.java rename to java/old/Project/SixDie.java diff --git a/java/Project/notes/CIS 217 Project 1 Winter 2021(4).docx b/java/old/Project/notes/CIS 217 Project 1 Winter 2021(4).docx similarity index 100% rename from java/Project/notes/CIS 217 Project 1 Winter 2021(4).docx rename to java/old/Project/notes/CIS 217 Project 1 Winter 2021(4).docx diff --git a/java/Project/notes/CIS 217 Project 1 Winter 2021(5).docx b/java/old/Project/notes/CIS 217 Project 1 Winter 2021(5).docx similarity index 100% rename from java/Project/notes/CIS 217 Project 1 Winter 2021(5).docx rename to java/old/Project/notes/CIS 217 Project 1 Winter 2021(5).docx diff --git a/java/Project/notes/notes.java b/java/old/Project/notes/notes.java similarity index 100% rename from java/Project/notes/notes.java rename to java/old/Project/notes/notes.java diff --git a/java/Project/notes/temp-notes.java b/java/old/Project/notes/temp-notes.java similarity index 100% rename from java/Project/notes/temp-notes.java rename to java/old/Project/notes/temp-notes.java diff --git a/java/Project/old-my-dice-game-test.java.old b/java/old/Project/old-my-dice-game-test.java.old similarity index 100% rename from java/Project/old-my-dice-game-test.java.old rename to java/old/Project/old-my-dice-game-test.java.old diff --git a/java/in-class-10-FEB-2021/SmartWatch.java b/java/old/in-class-10-FEB-2021/SmartWatch.java similarity index 100% rename from java/in-class-10-FEB-2021/SmartWatch.java rename to java/old/in-class-10-FEB-2021/SmartWatch.java diff --git a/java/in-class-10-FEB-2021/Watch.java b/java/old/in-class-10-FEB-2021/Watch.java similarity index 100% rename from java/in-class-10-FEB-2021/Watch.java rename to java/old/in-class-10-FEB-2021/Watch.java diff --git a/java/in-class-10-FEB-2021/WatchManager.java b/java/old/in-class-10-FEB-2021/WatchManager.java similarity index 100% rename from java/in-class-10-FEB-2021/WatchManager.java rename to java/old/in-class-10-FEB-2021/WatchManager.java diff --git a/java/plant-information/Flower.java b/java/old/plant-information/#Flower.java# similarity index 100% rename from java/plant-information/Flower.java rename to java/old/plant-information/#Flower.java# diff --git a/java/old/plant-information/Flower.java b/java/old/plant-information/Flower.java new file mode 100644 index 0000000..c324d36 --- /dev/null +++ b/java/old/plant-information/Flower.java @@ -0,0 +1,33 @@ +public class Flower extends Plant { + private boolean isAnnual; + private String color; + + public Flower () { + super(); + this.isAnnual = false; + this.color = "TBD"; + } + + public void setPlantType(boolean isAnnual){ + this.isAnnual=isAnnual; + } + public boolean getPlantType(){ + return this.isAnnual; + } + + public void setColorOfFlowers(String color){ + this.color=color; + } + public String getColorOfFlowers(){ + return this.color; + } + + @Override + public void printInfo(){ + System.out.println("Plant Information:"); + System.out.println("\tPlant name: " + name); + System.out.println("\tCost: " + cost); + System.out.println("\tAnnual: " + isAnnual); + System.out.println("\tColor of flowers: " + color + "\n"); + } +} diff --git a/java/plant-information/GardenManager.java b/java/old/plant-information/GardenManager.java similarity index 100% rename from java/plant-information/GardenManager.java rename to java/old/plant-information/GardenManager.java diff --git a/java/plant-information/MyGarden.java b/java/old/plant-information/MyGarden.java similarity index 100% rename from java/plant-information/MyGarden.java rename to java/old/plant-information/MyGarden.java diff --git a/java/plant-information/MyGardenJUnitTest.java b/java/old/plant-information/MyGardenJUnitTest.java similarity index 100% rename from java/plant-information/MyGardenJUnitTest.java rename to java/old/plant-information/MyGardenJUnitTest.java diff --git a/java/plant-information/Plant.java b/java/old/plant-information/Plant.java similarity index 100% rename from java/plant-information/Plant.java rename to java/old/plant-information/Plant.java diff --git a/java/week8/exceptions-input-file/NamesAndAges.txt b/java/week8/exceptions-input-file/NamesAndAges.txt new file mode 100644 index 0000000..bf9fc8d --- /dev/null +++ b/java/week8/exceptions-input-file/NamesAndAges.txt @@ -0,0 +1,5 @@ +Lee 18 +Lua 21 +Mary Beth 19 +Stu 33 +-2 diff --git a/java/week8/exceptions-input-file/main.java b/java/week8/exceptions-input-file/main.java new file mode 100644 index 0000000..31b7f6c --- /dev/null +++ b/java/week8/exceptions-input-file/main.java @@ -0,0 +1,58 @@ +import java.util.ArrayList; +import java.util.Scanner; +/* + * Same as the lab str vs int, except the input comes from a file + * instead of the keyboard. + * Use NamesAndAges.txt for input +*/ + +public class main { + + public static void main(String[] args) { + Scanner scnr = new Scanner(System.in); + String s = ""; + ArrayList userInputs = new ArrayList(); + String name; + int age; + + //Get input + while(s != "-1"){ + System.out.println("Enter a name and age. -1 to exit: "); + + //Get name or exit + s = scnr.next(); + + if (s.equals("-1")){ + System.out.println(); + break; + } + else{ + name = s; + } + + //Get age + + try{ + age = scnr.nextInt() +1; + } + catch(Exception e){ + System.out.println("Age must be an Integer\n" + + "Setting age to 0 "); + age = 0; + + } + //Finish line + scnr.nextLine(); + + //Add name plus new age to arr + userInputs.add(name + " " + Integer.toString(age)); + + System.out.println(); + } + + for (String S:userInputs){ + System.out.println(S); + } + } +} + diff --git a/java/week8/lab-string-vs-int/main.java b/java/week8/lab-string-vs-int/main.java new file mode 100644 index 0000000..ac06d88 --- /dev/null +++ b/java/week8/lab-string-vs-int/main.java @@ -0,0 +1,74 @@ +import java.util.ArrayList; +import java.util.Scanner; +/* + * Take in single-word first names and ages + * end with -1 + * program outputs list with age incremented + * program fails and throws exception if second input on a line is a string + * + * + * EX: + * Input: + * Lee 18 + * Lua 21 + * Mary Beth 19 + * Stu 33 + * -1 + * + * Output: + * Lee 19 + * Lua 22 + * Mary 0 + * Stu 34 +*/ + +public class main { + + public static void main(String[] args) { + Scanner scnr = new Scanner(System.in); + String s = ""; + ArrayList userInputs = new ArrayList(); + String name; + int age; + + //Get input + while(s != "-1"){ + System.out.println("Enter a name and age. -1 to exit: "); + + //Get name or exit + s = scnr.next(); + + if (s.equals("-1")){ + System.out.println(); + break; + } + else{ + name = s; + } + + //Get age + + try{ + age = scnr.nextInt() +1; + } + catch(Exception e){ + System.out.println("Age must be an Integer\n" + + "Setting age to 0 "); + age = 0; + + } + //Finish line + scnr.nextLine(); + + //Add name plus new age to arr + userInputs.add(name + " " + Integer.toString(age)); + + System.out.println(); + } + + for (String S:userInputs){ + System.out.println(S); + } + } +} +