Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cat {
- private String name;
- private String breed;
- private String color;
- private int age;
- private double weight;
- public Cat(String name, String breed, String color, int age, double weight) {
- this.name = name;
- this.breed = breed;
- this.color = color;
- this.age = age;
- this.weight = weight;
- }
- public Cat(String breed, String color, int age, double weight) {
- this.breed = breed;
- this.color = color;
- this.age = age;
- this.weight = weight;
- }
- public Cat(String color, int age, double weight) {
- this.color = color;
- this.age = age;
- this.weight = weight;
- }
- public Cat() {
- }
- public String getName() {
- return name;
- }
- public String getBreed() {
- return breed;
- }
- public String getColor() {
- return color;
- }
- public int getAge() {
- return age;
- }
- public double getWeight() {
- return weight;
- }
- public void setName(String name) {
- this.name = name;
- }
- public void setBreed(String breed) {
- this.breed = breed;
- }
- public void setColor(String color) {
- this.color = color;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public void setWeight(double weight) {
- this.weight = weight;
- }
- public void mnyau(){
- System.out.println("MNYAU-MNYAU");
- }
- public void print(){
- System.out.println();
- if (name == null) {
- this.name = "unkown";
- }
- if (breed == null){
- this.breed = "unkown";
- }
- System.out.println("Name: "+name);
- System.out.println("Breed: "+breed);
- System.out.println("Color: "+color);
- System.out.println("Age cat: "+age);
- System.out.println("Weight: "+weight);
- }
- @Override
- public String toString() {
- return "Cat{" + "name='" + name + '\'' +
- ", breed='" + breed + '\'' +
- ", color='" + color + '\'' +
- ", age=" + age +
- ", weight=" + weight +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement