Created
March 9, 2017 14:25
-
-
Save anonymous/e33b0c2fcae1e336784b16cd9eed7cce to your computer and use it in GitHub Desktop.
Parrot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main | |
{ | |
public static void main (String[] args) | |
{ | |
Parrot parrot1 = new Parrot(105, 50, "Popka", "yellow"); | |
Parrot parrot2 = new Parrot(140, 60, "Petrusha", "blue"); | |
System.out.println(parrot1.getName()); | |
System.out.println(parrot1.getFeathersAmount()); | |
parrot1.scratch(); | |
System.out.println(parrot1.getFeathersAmount()); | |
parrot1.say(); | |
System.out.println(parrot2.getName()); | |
System.out.println(parrot2.getFeathersAmount()); | |
parrot2.scratch(); | |
System.out.println(parrot2.getFeathersAmount()); | |
parrot2.say(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parrot{ | |
private int feathersAmount; | |
private int age; | |
private String name; | |
private String color; | |
Parrot(int feathersAmount, int age, String name, String color){ | |
this.feathersAmount = feathersAmount; | |
this.age = age; | |
this.name = name; | |
this.color = color; | |
} | |
public void say (){ | |
System.out.println(name +" stuppid!"); | |
} | |
public void scratch(){ | |
feathersAmount *= 0.9; | |
} | |
public int getFeathersAmount(){ | |
return feathersAmount; | |
} | |
public String getName(){ | |
return name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment