Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA PLEASE HELP The following is a UML diagram for a class. Write the code for

ID: 3917326 • Letter: J

Question

JAVA PLEASE HELP

The following is a UML diagram for a class. Write the code for this class.

Cat

- breed : String

- color : Color

- name : String

+ Cat( name : String)

+ Cat(name : String, breed : String, color : Color)

+ getName() : String

+ getColor() : Color

+ getBreed() : String

setColor(Color)

setBreed(Breed)

toString()

Cat

- breed : String

- color : Color

- name : String

+ Cat( name : String)

+ Cat(name : String, breed : String, color : Color)

+ getName() : String

+ getColor() : Color

+ getBreed() : String

setColor(Color)

setBreed(Breed)

toString()

Explanation / Answer

public class Cat
{

String name;
String breed;
String color;

public Cat(String name, String breed, String color)
{
this.name = name;
this.breed = breed;
this.color = color;
}

public String getName()
{
return name;
}
public String getBreed()
{
return breed;
}
public String getColor()
{
return color;
}
@Override
public String toString()
{
return("Hi I am "+ this.getName()+
". My breed and color is " +
this.getBreed()+"," + this.getColor());
}
public static void main(String[] args)
{
Cat obj= new cat("Tommy","Persian cat", "Black");
System.out.println(Tommy.toString());
}
}


output:
Hi I am Tommy

My breed and color is Persian cat , black

According to my understanding i am providing the program Thanks Have a great day.