Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class Chap5prob20_coinTOSS {
- private String sideUp = "";
- public Chap5prob20_coinTOSS() {
- sideUp = "heads";
- }
- //all other object specific methods
- public void settoss() {
- int toss = 0;
- Random test = new Random();
- toss = test.nextInt(2);
- if(toss == 0){
- sideUp = "heads";
- }
- else {
- sideUp = "tails";
- }
- }
- public String gettoss() {
- Chap5prob20_coinTOSS st;
- st = new Chap5prob20_coinTOSS();
- st.settoss();
- return sideUp;
- }
- }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement