forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.java
More file actions
44 lines (25 loc) · 720 Bytes
/
Dog.java
File metadata and controls
44 lines (25 loc) · 720 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
44
public class Dog extends Animal2{
public void digHole(){
System.out.println("Dug a hole");
}
public void changeVar(int randNum){
randNum = 12;
System.out.println("randNum in method value: " + randNum);
}
/* This private method can only be accessed through using other
* methods in the class */
private void bePrivate(){
System.out.println("In a private method");
}
public void accessPrivate(){
bePrivate();
}
// The constructor initializes all objects
public Dog(){
// Executes the parents constructor
// Every class has a constructor whether you make it or not
super();
// Sets bark for all Dog objects by default
setSound("Bark");
}
}