Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e33b0c2fcae1e336784b16cd9eed7cce to your computer and use it in GitHub Desktop.
Save anonymous/e33b0c2fcae1e336784b16cd9eed7cce to your computer and use it in GitHub Desktop.
Parrot
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();
}
}
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