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.

38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a
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?

* The value of the parameter 'blimp' when 'baffle' is invoked would be "rattle".
* The output of this program is (ik, rattle, ping zoop, boo-wa-ha-ha)
---

## Part 3: Stack Diagram and Program Output
Expand All @@ -40,13 +41,25 @@ Answer questions about stack diagrams and program output without running the pro
1. Draw a stack diagram that shows the state of the program the first time `ping` is invoked.
* 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.

* The diagram of the program the first time ping is invoked would go like
* main()
|
--> zoop()
|
--> baffle()
|
--> ping()

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.
```

---
---

## Part 4: Exploring Method Invocations

Expand All @@ -55,7 +68,9 @@ 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?
* If you invoke the value method and don't do anything with the result then the code still occurs and runs but whatever result comes of it will be discarded.
2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`.
* If you try to use a void method as part of an expression then you will get a compile-time error. This is because the void method doesn't produce a value that can be used in an expression. The command System.out.println("boo!") is a void command so adding a 7 won't do anything until the 7 is inside the parenthesis with the "boo!".

---

Expand All @@ -68,10 +83,23 @@ Draw a stack diagram that shows the state of the program the second time `zoop`
1. Draw a stack diagram that shows the state of the program the second time `zoop` is invoked.
* 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.

* The output would be
main()
|
--> zoop("just for", 5) // first invocation
|
--> clink(4)
|
--> zoop("breakfast ", 4) // second invocation

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
13 changes: 13 additions & 0 deletions src/Redesigndate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Redesigndate {
public static void main(String[] args) {
printAmerican("February", "Friday", 9, 2024);

printEuropean("Friday", 9, "February", 2024);
}
public static void printAmerican(String month, String day, int date, int year) {
System.out.println(day + ", " + month + " " + date + ", " + year);
}
public static void printEuropean(String day, int date, String month, int year) {
System.out.println(month + " " + date + ", " + day + ", " + year);
}
}
26 changes: 13 additions & 13 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);
public class Zippo { //1
public static void baffle(String blimp) { //7
System.out.println(blimp); //8
zippo("ping", -5); //9
}
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) { //3
if (flag < 0) { //4
System.out.println(quince + " zoop"); //10
} else { //5
System.out.println("ik"); //6
baffle(quince); //7
System.out.println("boo-wa-ha-ha"); //11
}
}

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