Skip to content

Instantly share code, notes, and snippets.

@Banafasto
Last active January 19, 2017 09:08
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 Banafasto/cd02e58dde1ef69f4ca48555747330b9 to your computer and use it in GitHub Desktop.
Save Banafasto/cd02e58dde1ef69f4ca48555747330b9 to your computer and use it in GitHub Desktop.
Lessons1Example1OOP
package com.gmail.kudr641.example1;
public class Cat {
private int age;
private int weight;
private String color;
private String name;
public Cat(int age, int weight, String color, String name){
this.age = age;
this.weight = weight;
this.color = color;
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void getVoice(){
System.out.println("May - May");
}
public void go(){
System.out.println("Cat go");
}
}
package com.gmail.kudr641.example1;
public class Runner {
public static void main(String[] args) {
Cat cat = new Cat(4, 3, "gray", "Barsik");
cat.getVoice();
cat.go();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment