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.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a
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 gets invoked is "rattle"

// The output of this program is; ik, rattle, ping zoop, boo-wa-ha-ha

---

## Part 3: Stack Diagram and Program Output
Expand All @@ -42,7 +46,19 @@ Answer questions about stack diagrams and program output without running the pro
* Regardless of your methodology, a picture of the programs state should be added to this Repo and committed.
2. What is the output by the following program?
* Paste your output in the bash code-block below.

Stack diagram;

Stack Diagram for the First Invocation of ping:
* Main method activation record: Local variables: args (String[])
* zoop method activation record: No local variables
* baffle method activation record: No local variables
* ping method activation record: No local variables

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

```

Expand All @@ -57,6 +73,14 @@ Explore method invocations and their consequences.
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;`.

When you invoke a value method and dont do anything with the result, the method will still execute but the return value is thrown out.

if you used a void method as part of an expression you would get a compilation error like ;

Error: bad operand types for binary operator '+'
first type: void
second type: int

---

## Part 5: Stack Diagram and Program Output
Expand All @@ -70,7 +94,13 @@ Draw a stack diagram that shows the state of the program the second time `zoop`
* 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.

The stack diagram is the same as mentioned before I believe, no changes to the diagram are needed

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

```

Expand Down
12 changes: 12 additions & 0 deletions src/RedesignDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class RedesignDate {
public static void main(String[] args) {
printAmerican("Monday", 22, "July", 2019);
printEuropean("Monday", 22, "July", 2019);
}
public static void printAmerican(String day, int date, String month, int year) {
System.out.printf("%s, %s %d, %d\n", day, month, date, year);
}
public static void printEuropean(String day, int date, String month, int year) {
System.out.printf("%s %d %s, %d\n", day, date, month, year);
}
}
23 changes: 12 additions & 11 deletions src/Zippo.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
public class Zippo {
public static void baffle(String blimp) {
System.out.println(blimp);
zippo("ping", -5);
public static void baffle(String blimp) { // 3
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");

public static void zippo(String quince, int flag) { // 4
if (flag < 0) { // 5
System.out.println(quince + " zoop"); // 6
} else {
System.out.println("ik");
baffle(quince);
System.out.println("boo-wa-ha-ha");
System.out.println("ik"); // 10
baffle(quince); // 11
System.out.println("boo-wa-ha-ha"); // 12
}
}

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