diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..ea71d50 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..94b8b21 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,12 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a 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? + - `blimp = ping` 4. What is the output of this program? + - `ik + rattle + ping zoop + boo-wa-ha-ha` --- @@ -40,10 +45,14 @@ 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. + * ![img.png](img.png) + * no variable pops up, but i think the value of`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. ``` --- @@ -55,7 +64,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? + - you may get a compiler error. Or Java may get mad and throw a red squiggly line where `return` should be. 2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`. + - this error message appears `java: not a statement`. --- @@ -68,10 +79,14 @@ 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. + * ![img_1.png](img_1.png) 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 diff --git a/img.png b/img.png new file mode 100644 index 0000000..f3d8fe3 Binary files /dev/null and b/img.png differ diff --git a/img_1.png b/img_1.png new file mode 100644 index 0000000..272f6c9 Binary files /dev/null and b/img_1.png differ diff --git a/src/RedesignDate.java b/src/RedesignDate.java new file mode 100644 index 0000000..2f1f8ad --- /dev/null +++ b/src/RedesignDate.java @@ -0,0 +1,32 @@ +public class RedesignDate { + + // Part 1 + + public static String printAmerican(String day, int date, String month, int year) { + String aTemplate = "%s, %s %dth, %d"; + System.out.printf(aTemplate, day, month, date, year); + return ""; + + } + + public static String printEuropean(String day, int date, int month, int year) { + String bTemplate = "%s, %02d.%02d.%d"; + System.out.printf(bTemplate, day, date, month, year); + return ""; + + } + + public static void twoLine() { + System.out.println("\n"); + + } + + public static void main(String[] args) { + printAmerican("Wednesday", 7, "February", 2024); + twoLine(); + printEuropean("Wednesday", 07, 02, 2024); + + + } + +} \ No newline at end of file diff --git a/src/Zippo.java b/src/Zippo.java index 04581a4..674b43d 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); + 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 } } diff --git a/src/Zoop.java b/src/Zoop.java index f9a1923..812430b 100644 --- a/src/Zoop.java +++ b/src/Zoop.java @@ -1,20 +1,20 @@ public class Zoop { public static void zoop() { - baffle(); - System.out.print("You wugga "); - baffle(); + baffle(); //3 + System.out.print("You wugga "); //7 + baffle(); //8 } public static void baffle() { - System.out.print("wug"); - ping(); + System.out.print("wug"); //4 //9 + ping(); //5 //10 } public static void ping() { - System.out.println("."); + System.out.println("."); //6 //11 } public static void main(String[] args) { - System.out.print("No, I "); - zoop(); - System.out.print("I "); - baffle(); + System.out.print("No, I "); //1 + zoop(); //2 + System.out.print("I "); //12 + baffle(); //13 } } \ No newline at end of file