I am trying to create a method entitled rolledOneOnlyOnce that takes in two integers as parameters and returns a Boolean. This method must be public and static. In this method, the integer parameters represent the values currently on each of the Game’s die (die1,die2 respectively). Here, you will want to return true if only one of the die’s value is 1. Otherwise, return false.

For, A method entitled snakeEyes that takes in two integers as parameters and returns a Boolean. This method must be public and static. In this method, the integer parameters represent the values currently on each of the Game’s die (die1,die2 respectively). Here, you will want to return true if only both of the die’s values are 1. Otherwise, return false. **I wrote return (d1 ==1) && (d2==1); and IT WORKED!!! **

**But not sure about the first one. **

What code should I write?

Recommended Answers

All 2 Replies

Have a look at Java's exclusive ORoperator - it's just what you need.

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.