Skip to content
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
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Redesign code from a previous exercise into methods that take parameters.
Review the flow of execution through the program [Zippo.java](src/Zippo.java), a program with multiple methods.

**Questions to Answer In This README.md:**
1. Write the number 1 next to the first line of code in this program that will execute.
2. Write the number 2 next to the second line of code, and so on until the end of the program.
3. What is the value of the parameter `blimp` when `baffle` gets invoked?
4. What is the output of this program?
1. Write the number 1 next to the first line of code in this program that will execute. Done.
2. Write the number 2 next to the second line of code, and so on until the end of the program. Done.
3. What is the value of the parameter `blimp` when `baffle` gets invoked? rattle.
4. What is the output of this program? ik rattle ping zoop boo-wa-ha-ha

---

Expand All @@ -43,7 +43,9 @@ Answer questions about stack diagrams and program output without running the pro
2. What is the output by the following program?
* Paste your output in the bash code-block below.
```bash

No, I wug.
You wugga wug.
I wug.
```

---
Expand All @@ -54,8 +56,10 @@ Answer questions about stack diagrams and program output without running the pro
Explore method invocations and their consequences.

**Questions to answer in the README.md via Markdown:**
1. What happens if you invoke a value method and don’t do anything with the result; that is, if you don’t assign it to a variable or use it as part of a larger expression?
2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`.
1. What happens if you invoke a value method and don’t do anything with the result; that is, if you don’t assign it to a variable or use it as part of a larger expression?
<br>Answer: Java/IntelliJ gives you a warning, but aside from that the method is executed and the value is discarded.
2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`.
<br>Answer: Compile error. Void methods don't return values, so they cannot be used in expressions or as values in variables.

---

Expand All @@ -71,7 +75,10 @@ Draw a stack diagram that shows the state of the program the second time `zoop`
2. What is the complete output?
* Paste your output in the bash code-block below.
```bash

just for
any not more
It's breakfast
!
```

## Submission
Expand Down
Binary file added src/BreakPointScreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/BreakPointScreenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/RedesignDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public class RedesignDate {

public static void printAmerican(String day, int date, String month, int year) {

String americanDate = String.format("%s, %s %d, %d", day, month, date, year);
System.out.println(americanDate);

}

public static void printEuropean(String day, int date, String month, int year) {

String formattedDate = String.format("%s %d %s %d", day, date, month, year);
System.out.println(formattedDate);

}

public static void main(String[] args) {

printAmerican("Monday", 22, "July", 2019);

printEuropean("Monday", 22, "July", 2019);

}
}
14 changes: 7 additions & 7 deletions src/Zippo.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
public class Zippo {
public static void baffle(String blimp) {
System.out.println(blimp);
zippo("ping", -5);
System.out.println(blimp); //4
zippo("ping", -5); //5
}
public static void zippo(String quince, int flag) {
if (flag < 0) {
System.out.println(quince + " zoop");
System.out.println(quince + " zoop"); //6
} else {
System.out.println("ik");
baffle(quince);
System.out.println("boo-wa-ha-ha");
System.out.println("ik"); //2
baffle(quince); //3
System.out.println("boo-wa-ha-ha"); //7
}
}

public static void main(String[] args) {
zippo("rattle", 13);
zippo("rattle", 13); //1
}
}