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..eefa08b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,9 @@ 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 - +C:\Users\diego\.jdks\openjdk-21.0.2\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53292,suspend=y,server=n -javaagent:C:\Users\diego\AppData\Local\JetBrains\IdeaIC2023.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath "C:\Users\diego\IdeaProjects\Java-Lab-004\out\production\Java-Lab-004;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\lib\idea_rt.jar" Zoop +Connected to the target VM, address: '127.0.0.1:53292', transport: 'socket' +No, I wug ``` --- @@ -57,6 +59,16 @@ 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;`. +## #1 +``` +If you invoke a method you and don't do anything with it nothing will happen. +The method will basically be useless. +``` +## #2 +``` +you get the error nessage :3:36 +java: not a statement. Which basically means that the compiler doesn't understand the code porbably because it's not returning anything. +``` --- ## Part 5: Stack Diagram and Program Output @@ -71,7 +83,11 @@ 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 - +C:\Users\diego\.jdks\openjdk-21.0.2\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\lib\idea_rt.jar=53448:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\diego\IdeaProjects\Java-Lab-004\out\production\Java-Lab-004 Part5 +just for +any not more +It's breakfast +! ``` ## Submission diff --git a/src/RedesignDate.java b/src/RedesignDate.java new file mode 100644 index 0000000..c5e0f2f --- /dev/null +++ b/src/RedesignDate.java @@ -0,0 +1,16 @@ +public class RedesignDate { + public static void main(String[] args) { + String day = "Thursday"; + String month = "July"; + int date = 18; + int year = 2019; + printAmerican(day, date, month, year); + printEuropean(day, date, month, year); +} + 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); + } +} diff --git a/src/StackDiagramPart5.PNG b/src/StackDiagramPart5.PNG new file mode 100644 index 0000000..e850d13 Binary files /dev/null and b/src/StackDiagramPart5.PNG differ diff --git a/src/StackDiagramZippo.PNG b/src/StackDiagramZippo.PNG new file mode 100644 index 0000000..d9f0ae9 Binary files /dev/null and b/src/StackDiagramZippo.PNG differ diff --git a/src/Test.java b/src/Test.java new file mode 100644 index 0000000..bf6f8d4 --- /dev/null +++ b/src/Test.java @@ -0,0 +1,5 @@ +public class Test { + public static void main(String[] args) { + System.out.println("boo!"); + } +} diff --git a/src/Zippo.java b/src/Zippo.java index 04581a4..764feda 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); //#5 + zippo("ping", -5); //#6 } public static void zippo(String quince, int flag) { - if (flag < 0) { - System.out.println(quince + " zoop"); + if (flag < 0) { //#2 and #7 + System.out.println(quince + " zoop"); //#8 } else { - System.out.println("ik"); - baffle(quince); - System.out.println("boo-wa-ha-ha"); + System.out.println("ik"); //#3 + baffle(quince); //#4 + System.out.println("boo-wa-ha-ha"); //#9 } } public static void main(String[] args) { zippo("rattle", 13); - } + } //#1 }