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

Help with Java Class How do I: TIP: Use Netbeans right click menu, Insert Code,

ID: 3846837 • Letter: H

Question

Help with Java Class

How do I:

TIP: Use Netbeans right click menu, Insert Code, Implement Method to have the IDE generate the methods for you; you will replace the throw exception statements with the source code you write

ArrayList // stores dice data for the sides of the die

TIP: member variables should have an access level modifier of private to protect the data

Add the parameter to the ArrayList representing the letters on the die

Use an enhanced for loop to output the letter on each of the six sides of the die

Update the class so that it implements interface IDie

TIP: Use Netbeans right click menu, Insert Code, Implement Method to have the IDE generate the methods for you; you will replace the throw exception statements with the source code you write

Add member variable of type:

ArrayList // stores dice data for the sides of the die

TIP: member variables should have an access level modifier of private to protect the data

Implement method addLetter; the method should:

Add the parameter to the ArrayList representing the letters on the die

Implement method displayAllLetters; the method should:

Use an enhanced for loop to output the letter on each of the six sides of the die

Explanation / Answer

You have not given your class name ans the code for the Die interface. The question talks about updatingpu an existing class ... Can you please post all the code you have and the complete question? Since I do not know what other methods / and their signatures in the Die interface, I have written the code based on the list given in the question. Please feel free to post a comment if any changes are needed. I will respond to your comment. If the answer helped, please don't forget to rate it.

import java.util.ArrayList;

public class Die implements IDie{

   private ArrayList<String> sides;

  

   public String rollDie()

   {

       //TODO: implement this method

       return null;

   }

   //adds a letter to sides

   public void addLetter(String letter)

   {

       sides.add(letter);

   }

  

   //displays all the sides of the die

   public void displayAllLetters()

   {

       System.out.println("The sides of the die are ");

       for(String s : sides)

           System.out.print(s + " ");

      

       System.out.println(); //print a newline at end

   }

}

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