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.

20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

---
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/RedesignDate.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Binary file added src/StackDiagramPart5.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/StackDiagramZippo.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("boo!");
}
}
16 changes: 8 additions & 8 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);
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
}