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.

42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,33 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a
**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.
A: public class Zippo { // 1
public static void baffle(String blimp) { // 6
System.out.println(blimp); // 7
zippo("ping", -5); // 8
}
public static void zippo(String quince, int flag) { // 2
if (flag < 0) { // 3
System.out.println(quince + " zoop"); // 10
} else { // 4
System.out.println("ik"); // 5
baffle(quince); // 11
System.out.println("boo-wa-ha-ha"); // 13
}
}

public static void main(String[] args) { // 15
zippo("rattle", 13); // 16
}
}
3. What is the value of the parameter `blimp` when `baffle` gets invoked?
4. What is the output of this program?
A: The value of "blimp" when "baffle" gets invoked is "rattle".
5. What is the output of this program?
A: ik
rattle
ping zoop
boo-wa-ha-ha


---

Expand All @@ -44,7 +69,9 @@ Answer questions about stack diagrams and program output without running the pro
* Paste your output in the bash code-block below.
```bash

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

---

Expand All @@ -55,23 +82,28 @@ 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?
A: The returned value is lost and the method is executed but the result is not used.
2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`.

A: The code will not compile because the void method does not return a value.
---

## Part 5: Stack Diagram and Program Output

**Objective:**
Draw a stack diagram that shows the state of the program the second time `zoop` is invoked in file [Part5.java](src/Part5.java). Determine the complete output.

**Questions:**
1. Draw a stack diagram that shows the state of the program the second time `zoop` is invoked.
**Questions:**Draw a stack diagram that shows the state of the program the second time `zoop` is invoked
1. .
* Hint: If you Google how to use IntelliJ's **BreakPoint** functionality, you can screenshot the **program state** instead of drawing it.
* Regardless of your methodology, a picture of the programs state should be added to this Repo and committed.
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/PingState1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/RedesignDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class RedesignDate {

static String hello = "Hello World!";
static String day = "Saturday";
static int date = 10;
static String month = "Feburary";
static int year = 2024;

public static void printAmerican(String day, int date, String month, int year) {
System.out.println("American: " + day + ", " + month + " " + date + ", " + year);
}

public static void printEuropean(String day, int date, String month, int year) {
System.out.println("European: " + day + " " + date + " " + month + " " + year);
}

public static void main(String[] args) {
System.out.println(hello);
printAmerican(day, date, month, year);
printEuropean(day, date, month, year);
}
}

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

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

// The value of "blimp" when "baffle" is invoked is "rattle"

Binary file added src/Zoopstate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.