-
-
Save Banafasto/cd02e58dde1ef69f4ca48555747330b9 to your computer and use it in GitHub Desktop.
Lessons1Example1OOP
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
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"); | |
} | |
} |
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
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