diff --git a/FirstSaturday.iml b/FirstSaturday.iml
index c02b99a..6c720f3 100644
--- a/FirstSaturday.iml
+++ b/FirstSaturday.iml
@@ -1,21 +1,8 @@
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ab780ca..f770fc3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,18 @@
groupId
FirstSaturday
1.0-SNAPSHOT
+
+ 11
+ 11
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
-
\ No newline at end of file
diff --git a/src/main/java/WriteIFs.java b/src/main/java/src/main/java/WriteIFs.java
similarity index 85%
rename from src/main/java/WriteIFs.java
rename to src/main/java/src/main/java/WriteIFs.java
index 0b9911a..3e59e38 100644
--- a/src/main/java/WriteIFs.java
+++ b/src/main/java/src/main/java/WriteIFs.java
@@ -10,12 +10,18 @@ public class WriteIFs
{
public void playerDied(boolean player1) {
- // Write an IF statement that checks “player1.isAlive()”
- // and if that’s false, calls “displayGameOver(player1)”
+ if(player1 != isAlive(true)){
+ displayGameOver(player1);
+ }
}
public String thermoSTAT(int room) {
+ if(tempurature(room) < 70){
+ heatOn();
+ } else{
+ coolOn();
+ }
// Write an IF statement that checks the
// “temperature(room)” and if that check is less than 70,
// calls “heatOn()” else calls “coolOn()”
@@ -26,6 +32,10 @@ public String thermoSTAT(int room) {
}
public void fireplaceControl(Object fireplace1) {
+ if(outsideTemp() < 50 && insideTemp() < 62){
+ startAFire(fireplace1);
+ }
+
// Write an IF statement that checks
// “outsideTemp()” is less than 50
// AND
@@ -35,6 +45,9 @@ public void fireplaceControl(Object fireplace1) {
}
public void checkFuel(double fuelLevel) {
+ if((fuelLevel) < 0.08){
+ refuel();
+ }
// Write an IF statement that checks “fuelLevel”
// and if that check is less than 0.08, calls “refuel()”
diff --git a/src/main/java/WriteLoops.java b/src/main/java/src/main/java/WriteLoops.java
similarity index 80%
rename from src/main/java/WriteLoops.java
rename to src/main/java/src/main/java/WriteLoops.java
index e7b1305..0ed3b61 100644
--- a/src/main/java/WriteLoops.java
+++ b/src/main/java/src/main/java/WriteLoops.java
@@ -15,8 +15,10 @@ public class WriteLoops {
public int oneToFive() {
int w = 0;
-
- // Write a FOR loop that counts from 1 to 10.
+ for(int i = 1; i < 5; i++) {
+ w += 1;
+ }
+ // Write a FOR loop that counts from 1 to 5.
// calling
w = w + 1;
// each time through the loop
@@ -27,7 +29,9 @@ public int oneToFive() {
public int oneToTen() {
int w = 0;
-
+ for(int i = 1; i < 10; i++){
+ w += 1;
+ }
// Write a FOR loop that counts from 1 to 10.
// calling
w = w + 1;
@@ -38,10 +42,11 @@ public int oneToTen() {
public int startAtTwentyOne() {
int w = 0;
-
+ for(int i = 21; i > 10; i--){
+ w = w + 1;
+ }
// Write a FOR loop that makes 10 iterations, start at 21.
// calling
- w = w + 1;
// each time through the loop
return w;
@@ -49,10 +54,12 @@ public int startAtTwentyOne() {
public int countDown() {
int w = 0;
+ for(int x = 100; x > 0; x--){
+ w += 1;
+ }
// Write a FOR loop that counts down from 100 to 0.
// calling
- w = w + 1;
// each time through the loop
return w;
@@ -61,19 +68,24 @@ public int countDown() {
public int byTwoTo32() {
int w = 0;
+ for(int i = 0; i <= 32; i+=2){
+ w = w + 1;
+ }
+
// Write a FOR loop from 0 to 32 by 2s.
// calling
- w = w + 1;
// each time through the loop
return w;
}
public int countDownFrom5000() {
int w = 0;
+ for(int i = 1; i < 5001; i+=11){
+ w = w + 1;
+ }
// Write a FOR loop from 1 to less than 5001 by 11s.
// calling
- w = w + 1;
// each time through the loop
return w;
@@ -82,10 +94,15 @@ public int countDownFrom5000() {
public int nestedFors() {
int w = 0;
+ for(int i = 0; i < 20; i++ ){
+ for(int j = 0; j <= 4; j++){
+ w = w + 1;
+ }
+ }
+
// Write a nested FOR loop(s), where one counts from
// 0 to less than 20 and the inner one counts from 0 to 4
// calling
- w = w + 1;
// each time through the inner loop
return w;
@@ -93,6 +110,13 @@ public int nestedFors() {
public int helloZipCode() {
int w = 0;
+ for(int i = 5; i <= 105; i++){
+ if(i > 51){
+ System.out.println("Hello Zipcode");
+ } else{
+ w += 1;
+ }
+ }
// Write a FOR loop that counts from 5 to 105. Put an IF
// statement inside the loop that checks the
@@ -100,7 +124,7 @@ public int helloZipCode() {
// prints “Hello Zipcode” instead of the statement w = w + 1;
// calling
- w = w + 1;
+ //w = w + 1;
// each time through the inner loop
return w;
@@ -129,11 +153,16 @@ public void simpleLoops() {
// After the loop is done, print “Honey, I’m Home!”
public int driveHome() {
int w = 0;
+ while(!gpsCurrentLocation().equals("Home")){
+ driveSomeMore();
+ w++;
+ }
+ System.out.println("Honey I'm Home");
// you need to use a .equals for two Strings.
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
@@ -146,19 +175,24 @@ public int driveHome() {
// is less than “highestScore” and if it is, adds “currentScore” to
// "runningScore"
// and then sets “currentScore” to “gameNextScore()”
- public int checkGameScore() {
+ public boolean checkGameScore() {
int w = 0;
int highestScore = 236;
int currentScore = gameNextScore();
int runningScore = 0;
+ while(runningScore <= highestScore){
+ runningScore += currentScore;
+ w++;
+ } currentScore = gameNextScore();
+
// do your while loop here
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
- return w; // >= 3;
+ return w >= 3; // >= 3;
}
// Rewrite the previous WHILE loop as a DO..WHILE loop.
@@ -169,10 +203,16 @@ public boolean checkGameScoreDoWhile() {
int currentScore = gameNextScore();
int runningScore = 0;
+ do{
+ currentScore = gameNextScore();
+ runningScore += currentScore;
+ w++;
+ }while(runningScore <= highestScore);
+
// do your while loop here
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
return w >= 3;
@@ -185,10 +225,15 @@ public boolean checkGameScoreDoWhile() {
public int checkServerStatus() {
int w = 0;
String adminPhoneNumber = "+1 202 456 1111";
-
+ while(serverIsRunning()){
+ w++;
+ waitFor(5);
+ } if(!serverIsRunning()){
+ sendEmergencyText("Help!", adminPhoneNumber);
+ }
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
return w;
@@ -199,10 +244,14 @@ public int checkServerStatus() {
// and if it is, add 7 to “i”
public int loop50by7() {
int w = 0;
-
+ int i = 7;
+ while(i < 50){
+ i += 7;
+ w++;
+ }
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
return w;
@@ -236,10 +285,13 @@ public int foo() {
public int rewriteFooAsFor() {
int w = 0;
int sumOfThrees = 0;
-
+ for(int i = 0; i < threes_array.length; i++){
+ w++;
+ sumOfThrees += threes_array[i];
+ }
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
System.out.print("The Sum is ");
@@ -253,10 +305,15 @@ public int rewriteFooAsFor() {
public int rewriteFooAsWhile() {
int w = 0;
int sumOfThrees = 0;
-
+ int i = 0;
+ while (i < threes_array.length){
+ sumOfThrees =+ threes_array[i];
+ i++;
+ w++;
+ }
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
System.out.print("The Sum is ");
@@ -274,12 +331,19 @@ public int rewriteFooAsWhile() {
// back.
public int manageYardAndJunior() {
int w = 0;
+ boolean yardNeedsMowed = true;
boolean onTime = true;
+ while (isSummer()){
+ if(yardNeedsMowed){
+ yellAtJuniorToMowLawn();
+ } sendJuniorBackToSchool(Boolean.toString(onTime));
+ w++;
+ }
// ADD YOUR CODE here.
// be sure to call
- w = w + 1;
+ // w = w + 1;
// each time inside the loop
return w;
@@ -294,6 +358,11 @@ public int tallyVote1() {
int w = 0;
int numberOfVotes = voteTallies.length;
+ for(int i =0; i < numberOfVotes; i++){
+ w++;
+ System.out.println(voteTallies[i]);
+ }
+
// calling
w = w + 1;
@@ -307,11 +376,18 @@ public int tallyVote1() {
// where you are.
public int tallyVote2() {
int w = 0;
+ int idx = 0;
int numberOfVotes = voteTallies.length;
+ while(idx < voteTallies.length-1){
+ w++;
+ System.out.println(voteTallies[idx]);
+ idx++;
+ }
+
// calling
- w = w + 1;
+ // w = w + 1;
// each time through the inner loop
return w;
diff --git a/src/test/java/WriteIFsTest.java b/src/test/java/src/test/java/WriteIFsTest.java
similarity index 100%
rename from src/test/java/WriteIFsTest.java
rename to src/test/java/src/test/java/WriteIFsTest.java
diff --git a/src/test/java/WriteLoopsTest.java b/src/test/java/src/test/java/WriteLoopsTest.java
similarity index 85%
rename from src/test/java/WriteLoopsTest.java
rename to src/test/java/src/test/java/WriteLoopsTest.java
index 04943ac..25f71b0 100644
--- a/src/test/java/WriteLoopsTest.java
+++ b/src/test/java/src/test/java/WriteLoopsTest.java
@@ -127,4 +127,25 @@ public void TestCheckServer()
WriteLoops writeLoo1 = new WriteLoops();
assertEquals(3, writeLoo1.checkServerStatus());
}
+
+ @Test
+ public void TestLoop50By70()
+ {
+ WriteLoops writeLoo1 = new WriteLoops();
+ assertEquals(7, writeLoo1.loop50by7());
+ }
+
+ @Test
+ public void FooForLoop(){
+ WriteLoops writeLoo1 = new WriteLoops();
+ assertEquals(7, writeLoo1.rewriteFooAsFor());
+ }
+
+ @Test
+ public void FooAsWhile(){
+ WriteLoops writeLoo1 = new WriteLoops();
+ assertEquals(7, writeLoo1.rewriteFooAsWhile());
+ }
+
+
}