forked from vogellacompany/codeexamples-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuck.java
More file actions
43 lines (36 loc) · 652 Bytes
/
Duck.java
File metadata and controls
43 lines (36 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package test;
public class Duck {
// Variable
private String name;
private boolean canFly;
// Constructor
public Duck(String name1, boolean canFly1) {
canFly = canFly1;
name = name1;
}
// Methode
public void quack(boolean doQuack) {
if (doQuack) {
canFly = true;
System.out.println("Quack");
} else {
System.out.println("Not");
}
}
// Methode
public void fly() {
if (canFly) {
System.out.println("I'm flying....");
} else {
System.out.println("Yeah, I'm waking....");
}
}
// Methode
public String getName() {
return name;
}
// Methode
public void setName(String name) {
this.name = name;
}
}