Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All test cases passed #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions BlueJ.FirstSaturday.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
82 changes: 50 additions & 32 deletions WriteIFs.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,59 @@
*/
public class WriteIFs
{
int tt_s = 1;
int x = 0;
int tt_t = 0;
String ss = "";
int oo1 = 61;
int oo2 = 49;
public boolean isAlive(boolean p) {
return !p;
}
private int tempurature(int t) {
return t+2;
}
private void heatOn() {
this.ss = "heating";
}
private void coolOn() {
this.ss = "cooling";
}

private int insideTemp() {
return oo1;
}
private int outsideTemp() {
return oo2;
}
private void startAFire(Object o) {
this.tt_s = 213;
}
private void refuel() {
this.x = 99;
}
private void displayGameOver(boolean b) {
this.ss = "Game Over!";
}

public void playerDied(boolean player1) {
// Write an IF statement that checks “player1.isAlive()”
// and if that’s false, calls “displayGameOver(player1)”
if(!isAlive(player1)){
displayGameOver(player1);
}

}

public String thermoSTAT(int room) {
// Write an IF statement that checks the
// “temperature(room)” and if that check is less than 70,
// calls “heatOn()” else calls “coolOn()”

if(tempurature(room) < 70){
heatOn();
} else {
coolOn();
}


return this.ss;
Expand All @@ -30,13 +71,17 @@ public void fireplaceControl(Object fireplace1) {
// AND
// “insideTemp()” is less than 62,
// calls “startAFire(fireplace1)”

if(outsideTemp() < 50 && insideTemp() < 62){
startAFire(fireplace1);
}
}

public void checkFuel(double fuelLevel) {
// Write an IF statement that checks “fuelLevel”
// and if that check is less than 0.08, calls “refuel()”

if(fuelLevel < .08) {
refuel();
}
}


Expand Down Expand Up @@ -67,34 +112,7 @@ public WriteIFs()
oo1 = 61;
oo2 = 49;
}
// associated routines

// associated routines
public boolean isAlive(boolean p) {
return !p;
}
private int tempurature(int t) {
return t+2;
}
private void heatOn() {
this.ss = "heating";
}
private void coolOn() {
this.ss = "cooling";
}

private int insideTemp() {
return oo1;
}
private int outsideTemp() {
return oo2;
}
private void startAFire(Object o) {
this.tt_s = 213;
}
private void refuel() {
this.x = 99;
}
private void displayGameOver(boolean b) {
this.ss = "Game Over!";
}

}
84 changes: 64 additions & 20 deletions WriteLoops.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.sun.org.apache.xpath.internal.SourceTree;


import java.awt.SystemTray;
import java.util.concurrent.ThreadLocalRandom;
Expand All @@ -20,7 +20,10 @@ public int oneToFive() {

// Write a FOR loop that counts from 1 to 10.
// calling
w = w + 1;

for(int i = 0; i < 5; i++){
w = w + 1;
}
// each time through the loop

// this will tell the test how many times the loop executed.
Expand All @@ -32,7 +35,9 @@ public int oneToTen() {

// Write a FOR loop that counts from 1 to 10.
// calling
w = w + 1;
for(int i = 0; i < 10; i++){
w = w + 1;
}
// each time through the loop

return w;
Expand All @@ -43,7 +48,10 @@ public int startAtTwentyOne() {

// Write a FOR loop that makes 10 iterations, start at 21.
// calling
w = w + 1;

for(int i = 21; i >=1; i-=2){
w = w + 1;
}
// each time through the loop

return w;
Expand All @@ -54,7 +62,10 @@ public int countDown() {

// Write a FOR loop that counts down from 100 to 0.
// calling
w = w + 1;

for(int i = 100; i > 0; i--){
w = w + 1;
}
// each time through the loop

return w;
Expand All @@ -65,7 +76,10 @@ public int byTwoTo32() {

// Write a FOR loop from 0 to 32 by 2s.
// calling
w = w + 1;
for(int i = 0; i <= 32; i += 2){
w = w + 1;
}

// each time through the loop
return w;
}
Expand All @@ -75,7 +89,9 @@ public int countDownFrom5000() {

// Write a FOR loop from 1 to less than 5001 by 11s.
// calling
w = w + 1;
for(int i = 1; i <5001; i += 11){
w = w + 1;
}
// each time through the loop

return w;
Expand All @@ -87,7 +103,12 @@ public int nestedFors() {
// 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;
for(int i = 0; i < 20; i++){
for(int j = 0; j <=4; j++){
w = w + 1;
}
}

// each time through the inner loop

return w;
Expand All @@ -102,7 +123,13 @@ public int helloZipCode() {
// prints “Hello Zipcode” instead of the statement w = w + 1;

// calling
w = w + 1;
for(int i = 5; i < 105; i++){
if(i > 51){
System.out.println("Hello Zipcode");
} else {
w = w + 1;
}
}
// each time through the inner loop

return w;
Expand Down Expand Up @@ -133,12 +160,13 @@ public int driveHome() {
int w = 0;

// you need to use a .equals for two Strings.

while(gpsCurrentLocation().equals("Not Home")){
// calling
driveSomeMore();
w = w + 1;
// each time through the inner loop


}
System.out.println("Honey, I'm Home!");
return w;
}

Expand All @@ -148,19 +176,23 @@ 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;

// do your while loop here

while(runningScore < highestScore){
runningScore = currentScore;
currentScore = gameNextScore();
w = w + 1;
}
// calling
w = w + 1;

// each time through the inner loop

return w; // >= 3;
return w >= 3;
}

// Rewrite the previous WHILE loop as a DO..WHILE loop.
Expand All @@ -172,9 +204,14 @@ public boolean checkGameScoreDoWhile() {
int runningScore = 0;

// do your while loop here

do{
runningScore += currentScore;
currentScore = gameNextScore();
w = w + 1;
} while(runningScore < highestScore);

// calling
w = w + 1;

// each time through the inner loop

return w >= 3;
Expand All @@ -188,9 +225,16 @@ public int checkServerStatus() {
int w = 0;
String adminPhoneNumber = "+1 202 456 1111";


while(serverIsRunning()){
waitFor(5);
w = w + 1;
}
if(!serverIsRunning()){
sendEmergencyText("Help!", adminPhoneNumber);
tryServerRestart("Help", adminPhoneNumber);
}
// calling
w = w + 1;

// each time through the inner loop

return w;
Expand Down
25 changes: 25 additions & 0 deletions out/production/BlueJ.FirstSaturday/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/*
10 changes: 10 additions & 0 deletions out/production/BlueJ.FirstSaturday/.vscode/launch.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"run": {
"default": "",
"items": []
},
"debug": {
"default": "",
"items": []
}
}
21 changes: 21 additions & 0 deletions out/production/BlueJ.FirstSaturday/BlueJ.FirstSaturday.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Loading