(求助)The Person Class
The Person ClassDefine a class called Person which has attributes called height , money , ticketCount and hasPass.
The money and height variables are floats representing the amount of money the person currently has and the person's height (in inches).
The ticketCount is an integer indicating the number of tickets the person
currently has and hasPass is a boolean indicating whether or not the
person has a pass to get on the rides (assume a person can have at most 1
pass).
Write a constructor & all necessary methods in the Person class so that the
following code produces the output as shown below:
class PersonTester {
public static void main(String args[]) {
Person mary;
mary = new Person(4.9f, 20.00f);
System.out.println(mary.height);
System.out.println(mary.money);
System.out.println(mary.ticketCount);
System.out.println(mary.hasPass);
System.out.println(mary); // Notice that the money is properly formatted
mary.ticketCount = 3;
System.out.println(mary);
mary.useTickets(2); // You have to write this method
System.out.println(mary);
mary.hasPass = true;
System.out.println(mary);
}
}
Here is the output that your program MUST produce:
4.9
20.0
0
false
4.9' person with $20.00 and 0 tickets
4.9' person with $20.00 and 3 tickets
4.9' person with $20.00 and 1 tickets
4.9' person with $20.00 and a pass
Make sure to test your class with the test code above BEFORE you continue.