Question: I need help with my Person Class PLEASE provide corrected codes if possible. My code: public class Person { private String name; private boolean hasDriverLicense;

I need help with my Person Class
PLEASE provide corrected codes if possible.
My code:
public class Person
{
private String name;
private boolean hasDriverLicense;
private int age;
private int height;
public Person(String name, boolean hasDriverLicense, int age, int height)
{
this.name = name;
this.hasDriverLicense = hasDriverLicense;
this.age = age;
this.height = height;
}
public String getName()
{
return name;
}
public boolean hasDriverLicense()
{
return hasDriverLicense;
}
public int getAge()
{
return age;
}
public int getHeight()
{
return height;
}
public Person clone()
{
return new Person(name, hasDriverLicense, age, height);
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass()!= o.getClass()) return false;
Person person =(Person) o;
return hasDriverLicense == person.hasDriverLicense &&
age == person.age &&
height == person.height &&
name.equals(person.name);
}
@Override
public String toString()
{
return String.format("Person [name=%s | age=%02d | height=%02d | has license/%s]",
name, age, height, hasDriverLicense ? "license" : "no license");
}
}
 I need help with my Person Class PLEASE provide corrected codes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!