Skip to content

Commit 427a6ec

Browse files
committed
added lecture 13 hardmode exercise
1 parent 9c8a6c3 commit 427a6ec

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

lec13/exercises/hardMode/Dog.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @author Josh Hug
3+
*/
4+
5+
public class Dog {
6+
private String name;
7+
private String breed;
8+
private double size;
9+
10+
public Dog(String n, String b, double s) {
11+
name = n;
12+
breed = b;
13+
size = s;
14+
}
15+
16+
public String toString() {
17+
return name + " is a " + breed + " weighing " + size + " lbs.";
18+
}
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @author Josh Hug
3+
*/
4+
5+
public class DogLauncher {
6+
public static void main(String[] args) {
7+
Dog d = new Dog("frankie", "barnacle dog", 22);
8+
System.out.println(d.toString());
9+
}
10+
}

lec13/exercises/hardMode/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Task 1: Convert the Dog and DogLauncher classes so that they are part of the ug.joshh.animal package. Successfully compile and run DogLauncher.
2+
3+
Task 2: Create an ExternalDogLauncher class that is NOT part of the package, but which is nonetheless capable of creating and printing out a Dog. Do not use import statements.
4+
5+
Task 2b: Modify your answer from task 2 so that it uses import statements.

0 commit comments

Comments
 (0)