Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This are API\'s for java and need to be typed in Java language. Styles Pile Clas

ID: 3815627 • Letter: T

Question

This are API's for java and need to be typed in Java language.

Styles Pile Class API Methods: Identifier: getSize0 Parameters int-The number of marbles remaining in the pile. Return Value Other Identifier: remove (int count t An int value representing the number of marbles to remove Parameters coun from the pile Return Other If someone attempts to remove more marbles than there are currently in the pile or a negative amount of marbles, this method should not modify the pile size and should print out an error message to the standard output (System.out Note that the Pile class does not enforce removing anything other than 1, 2, or 3 marbles. This is because that is a rule of the particular Nim game that is used in this assignment. Other versions of the game support removing different numbers of marbles and the Pile class should be general purpose Identifier: printPileo Parameters Value Other This method should print a graphical representation of the pile to the console. If the pile is sufficiently large, the output should be broken up across multiple lines so that it is easier to read. Asterisks or other characters such as the lowercase co an be used to represent marbles Constructor Methods: Identifier: Pile(int size) Parameters size The number of marbles that the pile should start with. Return Other

Explanation / Answer

Here is the code for you:

class Pile
{
    int numberOfMarbles;
    Pile(int size)
    {
       numberOfMarbles = size;
    }
    public int getSize()
    {
       return numberOfMarbles;
    }
    public void remove(int count)
    {
       if(count < 0 || count > numberOfMarbles)
           System.out.println("Can't modify the pile, with specified count.");
       else
           numberOfMarbles -= count;  
    }
    void printPile()
    {
       for(int i = 0; i < numberOfMarbles; i++)
       {
          System.out.print("*" + " ");
          if((i+1) % 5 == 0)
              System.out.println();
       }
       System.out.println();
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote