Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cat {
- private String name;
- private int age;
- public Cat() {
- }
- public Cat(String name, int age) {
- this.name = name;
- this.age = age;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public static void main(String[] args) {
- Cat Filemon = new Cat();
- String cat_name;
- int cat_age;
- Filemon.setName("Filemon");
- Filemon.setAge(21);
- cat_name = Filemon.getName();
- cat_age = Filemon.getAge();
- System.out.println("Cat has name " + cat_name + " and is " + cat_age + " years old.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement