Hello, i have a class "Die" and a class "PairOfDice" pair of dice extends die. i need to instance variables of type die in pairofdice constructor... i think.
here are constructors for die and pairofdie.. we learned all of this earlier this semester but apparently i didn't learn it well cause i can't remember how to do it. heres my constructors.

public Die()
   {
       sides=6;
    }
public PairOfDice()
    {
       
       super();
       
       
    }

i dont really get why they want us to create it like this when i can simply create 2 objects of die and roll each of those. but it instead wants both dice to be in one class i think?, im assuming it wants us to simulate rolling two dice as if you had them in your hand. so thats why. but i still don't understand how to do that. you dont gotta give me the answer but i just need help

Class structure looks dumb to me. 2Dice is not a "kind of " Die.
It would make more sense to have a (non-subclassed) class called "HandfullOfDice" that took an int numberOfDie as a param on the constructor, had a list of Die objects as an instance variable, and had public methods like rollAllDice and getTotalScore etc.

commented: agreed +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.