Question
Please answer as soon as possible. Using Java create the following classes below. Person Create a class called Person , with private instance variables, accessors,
Please answer as soon as possible.
Using Java create the following classes below.
Person Create a class called Person, with private instance variables, accessors, mutators, and constructor parameters for the following data: First name (a String; cannot be empty nor null), last name (a String; cannot be empty nor null), and year of birth (an int; cannot be zero nor any year later than the current year).
The constructor must call its own mutator methods, which will be private methods.
Add another instance variable called x, which is a double and which has no visibility modifier
Test Create another class called Test, which has a main method exactly as we learned in class:
public static void main(String[] args)
The Test classs main method will accept four command line arguments (Run Run Configurations Arguments Program arguments) in the following order:
First name, last name, year of birth, and x value.
The main() method creates a Person object using the commandline arguments, as follows:
Person p = new Person(args[0], args[1], Integer.parseInt(args[2]));
p.x = Double.parseDouble(args[3]));
but only if in fact there are four commandline arguments. If there are not exactly four, instead simply System.out.println(Wrong number of arguments) and do nothing else.
If there are four arguments, then the main method must print the Person objects accessor methods for first name, last name, and year of birth. It must also print the Person objects x value directly.
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