Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class Person { // PLEASE START YOUR CODE HERE // =========================== // =========================== // PLEASE END YOUR CODE HERE //constructor public Person(String firstName, String
public class Person { // PLEASE START YOUR CODE HERE // ===========================
// =========================== // PLEASE END YOUR CODE HERE
//constructor public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; }
public String toString() { return firstName + " " + lastName; }
}
You can never be too careful with your data privacy! Identity theft is a real issue... but we hope you don't have issues with it today! Today's "PoD.java' example creates a person and then creates another person (the identity theft) that has the same identity' (at the moment, they will just have the same first and last names - they are still two different people/objects!). POD.java' makes use of the Person class. You are going to write the Person class in Person.java You've been given an empty Person class. Inside this empty class, you will create the instance variables firstName and lastName. We have given you a constructor which takes in the first and last name and assigns them to those fields. We have also created a 'toString()' (accessor/getter) method to output the first and last names separated by one space. The main method in PoD.java' has been written for you. It reads in 2 strings, instantiates the class Person (once as the targeted person and another the identity theft's 'copy of that same person), and then prints out the result using the 'toString method. Details Input The following input values are expected: a string (firstName): the first name of the person (also used by the identity theft) a string (lastName): the last name of the person (also used by the identity theft) Processing Person.java: (this is where you need to do your work) Person -firstName: String - lastName: String +Person (firstName: String, lastName: String +toString(): String Create instance variables: o a string firstName: the first name of the person o a string lastName: the last name of the person A constructor is already created for you which takes in the first and last name and assigns them to the appropriate fields A toString() method exists which returns the first and last name separated by a space POD.java: (done for you) Read in two strings (first name of person, followed by last name) Instantiate the class Person twice . First, the person that is the target Second, the identity theft (a "copy of the target person) Output the results using the toString() method of Person.java It will be of the format: firstName + " " + lastName Sample Input/output (from POD.Java): Sample Input Sample Output Angela Siegel Angela Siegel Angela Siegel Mickey Mickey Mouse Mickey Mouse Mouse 1- /** * CSCI 1110 * @author ASiegel and YOU 3 public class Person // PLEASE START YOUR CODE HERE // =========================== // PLEASE END YOUR CODE HERE // constructor public Person(String firstName, String lastName) this.firstName = firstName; this.lastName = lastName; public String toString() return firstName + " " + lastNameStep 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