Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please use this code for person and app. follow all the steps below to create the code. make sure its correct. Person Class: public class
please use this code for person and app. follow all the steps below to create the code. make sure its correct.
Person Class:
public class Person{
private String name;
private int weight;
private String hometown;
private String highSchool;
public Person(){
this.name="";
this.weight=0;
this.hometown="N/A";
this.highSchool="N/A";
}
public Person(String name, int weight, String hometown, String highSchool) {
this.name = name;
this.weight = weight;
this.hometown = hometown;
this.highSchool = highSchool;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getHometown() {
return hometown;
}
public void setHometown(String hometown) {
this.hometown = hometown;
}
public String getHighSchool() {
return highSchool;
}
public void setHighSchool(String highSchool) {
this.highSchool = highSchool;
}
@Override
public String toString() {
return "Person{" + "name=" + name + ", weight=" + weight + ", hometown=" + hometown + ", highSchool=" + highSchool + '}';
}
}
App Class:
public class App {
public static void main(String[] args){
Person p1=new Person("Marcus Allen",200,"Upper Marlboro, Md.","Dr. Henry A. Wise, Jr.");
Person p2=new Person("Kyle Alston",180,"Robbinsville, N.J.","Robbinsville");
Person p3=new Person("Troy Apke",220,"Mt. Lebanon, Pa.","Mount Lebanon");
Person p4=new Person("Matthew Baney",225,"State College, Pa.","State College");
Person p5=new Person();
System.out.println(p1);
System.out.println(p2);
System.out.println(p3);
System.out.println(p4);
System.out.println(p5);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started