Question: JAVA please! thanks For this part of the lab, you'll be writing methods to work with classes and objects. Create a new project, called YOURNAME

JAVA please! thanks

For this part of the lab, you'll be writing methods to work with classes and objects.

  1. Create a new project, called YOURNAME_Lab1BClass.
    • You should consider developing the methods for this project incrementally.

  1. Now create another class inside of your project. Go to the Project Explorer panel, right click on the project name and select New -> Class.
    • Change the name of the class after it opens from Class1 to Person.

  1. Inside of your Person class add two class variables, one for first and one for last name.

  1. Create a default (no parameters) constructor method that sets their first name to "Bob and last name to Smith.

  1. Create an overloaded constructor method that takes in two parameters and sets their names to them. One parameter will be their first name and the second will be their last name.

  1. Create a getter/accessor method and setter/mutator method for both their first and last names.

  1. Lastly, create an overriden toString method that will return the persons first then last name.
    • Hint: The method header would be:

@Override

public String toString()

  1. In your main method, create an object/instance of your Person class using the default constructor.

  1. Create another Person using the overloaded constructor. Have the values that are passed in as arguments come from user input (Scanners nextLine).

  1. Directly print out both peoples values using the toString method.
    • Hint: The toString method is automatically called when an object/instance is placed into a WriteLine method call.

  1. Now change one persons first name to Aly and the other persons last name to Sanchez.
    • Hint: Use the setters/mutators to do so. Please do not create two entirely new objects.

  1. Finally, print out both names for both people using the getters/accessors.

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!