Skip to content

Commit bf9a05a

Browse files
committed
Added ability to swim
* Added Foot::flap() to advance the location of the penguin by 2 * Updated comment
1 parent 6a92fa2 commit bf9a05a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/animals/Penguin.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ public Penguin( int age,
4141

4242
public void waddle()
4343
{
44-
System.out.println( "Creating a penguin" );
44+
System.out.println( "Waddling" );
4545
leftFoot.moveForward();
4646
rightFoot.moveForward();
4747
}
48+
49+
public void swim()
50+
{
51+
System.out.println( "Swimming" );
52+
rightFoot.flap();
53+
leftFoot.flap();
54+
}
4855
}

src/animals/parts/Foot.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ public void moveForward()
2121
{
2222
location++;
2323
}
24+
25+
public void flap()
26+
{
27+
location += 2;
28+
}
2429
}

0 commit comments

Comments
 (0)