Skip to content

Commit ee0a529

Browse files
committed
Exercise 4 Solutions
1 parent 464f103 commit ee0a529

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
No, I wug.
2+
You wugga wug.
3+
I wug.
4+
5+
If you invoke baffle at the end of the ping method, you will get an infinite loop.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
public class Encapsulate {
2+
3+
public static void printAmerican(String day, String month, int date, int year) {
4+
System.out.println(day + ", " + month + " " + date + ", " + year);
5+
6+
}
7+
8+
public static void printEuropean(String day, int date, String month, int year) {
9+
System.out.println(day + " " + date + " " + month + " " + year);
10+
}
11+
12+
public static void main(String[] args) {
13+
String month = "December";
14+
String day = "Friday";
15+
int date = 1;
16+
int year = 2017;
17+
printAmerican(day, month, date, year);
18+
printEuropean(day, date, month, year);
19+
20+
21+
//// American Format output
22+
// System.out.println("American Format:");
23+
// System.out.println(day + ", " + month + " " + date + ", " + year);
24+
//// European Format:
25+
// System.out.println("European Format:");
26+
// System.out.println(day + " " + date + " " + month + " " + year);
27+
28+
}
29+
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Parameters {
2+
3+
public static void zool(int number, String petName, String street) {
4+
System.out.println("Your number: " + number);
5+
System.out.println("Your first pet: " + petName);
6+
System.out.println("The street: " + street);
7+
}
8+
9+
public static void main(String[] args) {
10+
int value = 11;
11+
String firstPet = "Chris the chicken";
12+
String street = "Avalanche road";
13+
zool(value, firstPet, street);
14+
}
15+
16+
}
17+

ch04/PrintTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public static void main(String[] args) {
1212
printTime(hour, minute);
1313
}
1414

15-
}
15+
}git

0 commit comments

Comments
 (0)