📜  将 Safe 类型的实例变量添加到 Room 类.这个实例变量应该在 Room 的构造函数中初始化,并且应该定义一个适当的查询来获取它. - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:34.465000             🧑  作者: Mango

代码示例1
public class PairOfDice {

    public int die1 = 3;   // Number showing on the first die.
    public int die2 = 4;   // Number showing on the second die.

    public void roll() {
            // Roll the dice by setting each of the dice to be
            // a random number between 1 and 6.
         die1 = (int)(Math.random()*6) + 1;
         die2 = (int)(Math.random()*6) + 1;
    }
    
} // end class PairOfDice