Write My Paper Button

WhatsApp Widget

Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models…

Homework Help Question & Answers

Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models…

Solve this using Java for an Intro To Java Class.

Provided files:

Person.java

/**  * Models a person  */ public class Person {     private String name;     private String gender;     private int age;          /**      * Consructs a Person object      * @param name the name of the person      * @param gender the gender of the person either       * m for male or f for female      * @param age the age of the person      */     public Person(String name, String gender, int age)     {         this.name = name;         this.gender = gender;         this.age = age;     }          /**      * gets the age of this Person      * @return the age of this Person      */     public int getAge()     {         return age;     }          /**      * gets the gender of this Person      * @return the gender of this Person      */     public String getGender()     {         return gender;     }          /**      * gets the name of this Person      * @return the name of this Person      */     public String getName()     {         return name;     }          /**      * Increases the age of this Person by 1 year      */     public void birthday()     {         age = age + 1;     } } 

Starter File for solution:

/**
* Models an Insurance client
*/
public class Insurance
{
private Person client;

/**
* Constructs an Insurance object with the given Person
* @param p the Person for this Insurance
*/
public Insurance(Person p)
{
client = p;
}
}

And here is the tester file:

/**  * Test the Insurance class  */ public class InsruanceTester {     public static void main(String[] args)     {         Insurance policy = new Insurance(            new Person("Carlos", "m", 15));         System.out.println(policy.clientAge());         System.out.println("Expected: 15");         policy.incrementAge();         System.out.println(policy.clientAge());         System.out.println("Expected: 16");         System.out.println(policy.clientGender());         System.out.println("Expected: m");                     policy = new Insurance(            new Person("Ashwanee", "f", 25));         System.out.println(policy.clientAge());         System.out.println("Expected: 25");         policy.incrementAge();         System.out.println(policy.clientAge());         System.out.println("Expected: 26");         System.out.println(policy.clientGender());         System.out.println("Expected: f");              } } 
0 0
Add a comment
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?