forked from mpmenne/launchcode-java-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
53 lines (46 loc) · 1.07 KB
/
Copy pathAnimal.java
File metadata and controls
53 lines (46 loc) · 1.07 KB
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
45
46
47
48
49
50
51
52
53
import java.util.Scanner;
/**
* Created by dshook on 4/30/15.
*
* Things to discuss today:
*
* Inheritance
* structure / design
* properties
* methods
* constructors
* accessing properties from base classes
* Polymorphism
*
* User Input
* Scanner
* Dialogs
*
* ----------------------------------------
*
* Git: fetching from upstream
* git remote add upstream https://github.com/dsshook/launchcode-java-class
* Creating new modules/psets
* Pset 2a, 2b, 2c
*
*/
public class Animal {
private String name;
private String foodSource;
public Animal(String name, String food) {
this.name = name;
this.foodSource = food;
}
public void eat() {
System.out.println("I am eating " + this.foodSource);
}
public void sleep() {
System.out.println("zzzzzzzz");
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Please enter a number");
String x = s.next();
System.out.println("You gave me the number: " + x);
}
}