diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..cbbff6a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 40c2bd8..e37f31b 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,16 @@ 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. +(Numbered in Zippo.java) 2. Write the number 2 next to the second line of code, and so on until the end of the program. +(Numbered in Zippo.java) 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 --- @@ -43,7 +50,7 @@ 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 ``` --- @@ -55,7 +62,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 a value method and don't do anything with the result, ths returned value can be ignored. The program and method still executes, but there is extra code that does not serve purpose. 2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`. +If you use this void method, a compilation error will result, where the void method does not return a value, and this expression expects a value for it. --- @@ -71,7 +80,9 @@ 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 - +No, I wug. +You wugga wug. +I wug. ``` ## Submission diff --git a/StackDiagram1.PNG b/StackDiagram1.PNG new file mode 100644 index 0000000..563caae Binary files /dev/null and b/StackDiagram1.PNG differ diff --git a/StackDiagram2.PNG b/StackDiagram2.PNG new file mode 100644 index 0000000..fb75058 Binary files /dev/null and b/StackDiagram2.PNG differ diff --git a/src/RedesignDate.java b/src/RedesignDate.java new file mode 100644 index 0000000..f950007 --- /dev/null +++ b/src/RedesignDate.java @@ -0,0 +1,17 @@ +import java.util.*; +public class RedesignDate { + + public static void main(String[] args) { + printAmerican("Saturday", 10, "February", 2024); + + printEuropean("Saturday", 10, "February", 2024); + } + + public static void printAmerican(String day, int date, String month, int year) { + + System.out.println(day + ", " + month + " " + date + ", " + year); + } + public static void printEuropean(String day, int date, String month, int year) { + System.out.println(day + ", " + date + " " + month + ", " + year); + } +} diff --git a/src/Zippo.java b/src/Zippo.java index 04581a4..d14eb84 100644 --- a/src/Zippo.java +++ b/src/Zippo.java @@ -1,19 +1,19 @@ public class Zippo { - public static void baffle(String blimp) { - System.out.println(blimp); - zippo("ping", -5); + 3 public static void baffle(String blimp) { + 4 System.out.println(blimp); + 5 zippo("ping", -5); } public static void zippo(String quince, int flag) { if (flag < 0) { - System.out.println(quince + " zoop"); + 6 System.out.println(quince + " zoop"); } else { - System.out.println("ik"); + 2 System.out.println("ik"); baffle(quince); System.out.println("boo-wa-ha-ha"); } } - public static void main(String[] args) { + 1 public static void main(String[] args) { zippo("rattle", 13); } }