Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class called Person class. The Person class contains Two instance variable named name (of type String) and age (of type int) . A
Write a class called Person class. The Person class contains Two instance variable named name (of type String) and age (of type int) . A constructor that creates a Person instance with the given parameters. It must assign age after confirming the argument passed is not negative; if a negative argument is passed, the constructor should set age to 0 . Getters and setters for instance variables name and age . A toString() that returns a short description of the instance. A yearPasses() method that increases the age by 1 Write the Person class in the answer box below. Note - keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks For example Test Result Person p- new Person(Joe 12)Joe (12) System.out.println(p)
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