Question: JAVA Person.java - This class represents a single person with their cart. It has the comments describing each of the methods we need to complete.

JAVA

Person.java - This class represents a single person with their cart. It has the comments describing each of the methods we need to complete.

Please add JAVADoc

//class representing a person and their cart class Person { //Add more instance variables here... //private or protected only! //Sets up a person with a given number of items. public Person(int numItems) { //O(1) //throws an IllegalArgumentException if numItems is //invalid (the person has less than one item) } //Gets how many items the person still has. public int getNumItems() { //O(1) return -1; } //Removes one item from this person (i.e. "checks out" //one item from this person. public void removeItem() { //O(1) } //Indicates whether or not this person has any more //items left to "check out". public boolean done() { //O(1) return false; } //------------------------------------------------------------- // Main Method For Your Testing -- Edit all you want //------------------------------------------------------------- public static void main(String[] args){ Person mason = new Person(2); if (mason.getNumItems() == 2 && !mason.done()){ System.out.println("Yay 1"); } mason.removeItem(); boolean ok = (mason.getNumItems() == 1); mason.removeItem(); if ( ok && mason.done()){ System.out.println("Yay 2"); } } //------------------------------------------------------------- // DO NOT EDIT ANYTHING BELOW THIS LINE EXCEPT TO ADD JAVADOCS //------------------------------------------------------------- //provided toString() method public String toString() { return "Person("+getNumItems()+")"; } }

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!