Need help with this book problem...Pig game...can ANYONE help!??

I need help with the following book problem...could someone write this code for me?? Thanks!!
First design and implement a class called PairOfDice, composed of two six-sided Die objects. Using the PairOfDice class, design and implement a class to play a game called Pig. In this game, the user competes against the computer. On each turn, the current player rolls a pair of dice and accumulates points. The goal is to reach 100 points before your opponent does. If, on any turn, the player rolls a 1, all points accumulated for that round are forfeited and control of the dice moves to the other player. If the player rolls two 1s in one turn, the player loses all points accumulated thus far in the game and loses control of the dice. The player may voluntarily turn over the dice after each roll. Therefore the player must decide to either roll again (be a pig) and risk losing points, or relinquish control of the dice, possibly allowing the other player to win. Implement the computer player such that it always relinquishes the dice after accumulating 20 or more points in any given round.
I realize this is a long code, so it would be greatly appreciated to anyone who writes this one for me, or can at least give me any parts of it. I honestly have no clue how to do this because our professor is a dumbass and just expects us to know how to do this...he doesn't teach us this stuff...don't ask. Anyways, thanks for taking the time to read this and I hope someone helps out!! Thank you in advance to anyone who does!!!

Nasty comments? It's not a matter of not liking you, it's a matter of responding to the
"I'ts everyone else's fault but mine" attitude of your post.
If you are genuine, the program is very easy to write, so, your Professor is correct when he said you should
be able to do it. I'm still very much in the beginner category at java, and it took me only 20 mins to write
(+5 mins to design it on paper). 2 classes in one file < 100 lines. Most of the regulars here would do it in half the time / half the lines.
All of the clues are in the description, break them down into their various if / else conditions. Write it down on paper.
Have a go. Try to achieve something. Post what you've tried, no-one will laugh at you, and you will be
pleasanty surprised at the level of help you will get when you've "obviously" made some effort.
Again, have a go. If you don't like problem-solving, then you don't like programming. So, you gotta ask
yourself - "what am I doin' here?"

Similar Messages

  • HT5622 I need help finding a movie that I downloaded, can anyone help me with this?

    Hello, I need help finding a movie that I downloaded, can anyone help me with this?

    If you downloaded it to your iTunes library it will be in the Movies folder.  If you downloaded it to an iOS device you will find it in the Videos app.  This explains how to redownload previously purchased videos (available in some locations as long as the studio permits it): http://support.apple.com/kb/PH12283.

  • TS1702 I purchased 2 packages of gems for skylanders and only received 1 package. Got email receipts and tried to report problem on ipad2 and it keeps coming up with to many https redirects. Can anyone help? Just want my gems :).

    I purchased 2 packages of gems for skylanders and only received 1 package. Got email receipts and tried to report problem with link in email on my ipad2 and it keeps coming up with to many https redirects. Can anyone help? Just want my gems :).

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • I connected my ipod touch 4g wi-fi with laptop ad hoc network....it's showing wi-fi signals but internet is not working...what is the problem in that can anyone help me...inadvances thanks

    I connected my ipod touch 4g wi-fi with laptop ad hoc network....it's showing wi-fi signals but internet is not working...what is the problem in that can anyone help me...inadvances thanks

    my laptop is Windows 7 and ip is this
    192.168.102.12
    255.255.255.0
    192.168.102.1
    DNS
    192.168.254.2
    192.168.254.3
    in ipod touch 4g is DHCP and its showing
    ip address 169.254.192.139
    subnet mask 255.255.0.0.
    remaining all blank

  • I have recently changed my apple id and password, but when i try to access music on an external hard drive that i bought on iTunes it asks me to authorize my computer with my old apple id? can anyone help?

    I have recently changed my apple id and password.  When i try to access music that i bought on itunes on an external hard drive,  it asks me to authorize my computer with my old apple id? can anyone help?

    Please try to sign in at https://appleid.apple.com
    Check if your new username/email address is verfied
    If this works, delete your account on your iPhone (Settings > iCloud)
    Sign back in

  • I can't sync my Nokia N8 with my iMac ( iOs Lion). Can anyone help?

    I cant sync Nokia n8 with my iMac ( iOS Lion). Can anyone help pelase?

    Hello zeeman1953,
    Thank you for using Apple Support Communities.
    This article should help you troubleshoot your issues with pairing your iPhones and autos:
    If you can't use a Bluetooth accessory or car kit
    Regards,
    Jeff D. 

  • My iphone is blocked and I am being told to pluig it in to itunes but the itunes it was set up with is not recognizing the device - can anyone help?

    My iphone is blocked and I am being told to plug it in to itunes but the itunes it was set up with is not recognizing the device - can anyone help? 

    I also live in the United States so redownloading shouldn't be a problem.

  • Please I really need help with this video problem.

    Hi!
    Please I need help with this app I am trying to make for an Android cellphone and I've been struggling with this for a couple of months.
    I have a main flash file (video player.fla) that will load external swf files. This is the main screen.When I click the Sets Anteriores button I want to open another swf file called sets.swf.The app is freezing when I click Sets Anteriores button
    Here is the code for this fla file.
    import flash.events.MouseEvent;
    preloaderBar.visible = false;
    var loader:Loader = new Loader();
    btHome.enabled = false;
    var filme : String = "";
    carregaFilme("home.swf");
    function carregaFilme(filme : String ) :void
      var reqMovie:URLRequest = new URLRequest(filme);
      loader.load(reqMovie);
      loader.contentLoaderInfo.addEventListener(Event.OPEN,comeco);
      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progresso);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completo);
      palco.addChild(loader); 
    function comeco(event:Event):void
              preloaderBar.visible = true;
              preloaderBar.barra.scaleX = 0;
    function progresso(e:ProgressEvent):void
              var perc:Number = e.bytesLoaded / e.bytesTotal;
              preloaderBar.percent.text = Math.ceil(perc*100).toString();
              preloaderBar.barra.scaleX =  perc;
    function completo(e:Event):void
              preloaderBar.percent.text = '';
              preloaderBar.visible = false;
    btHome.addEventListener(MouseEvent.MOUSE_DOWN,onHomeDown);
    btHome.addEventListener(MouseEvent.MOUSE_UP,onHomeUp);
    btSets.addEventListener(MouseEvent.MOUSE_DOWN,onSetsDown);
    btSets.addEventListener(MouseEvent.MOUSE_UP,onSetsUp);
    btVivo.addEventListener(MouseEvent.MOUSE_DOWN,onVivoDown);
    btVivo.addEventListener(MouseEvent.MOUSE_UP,onVivoUp);
    btHome.addEventListener(MouseEvent.CLICK,onHomeClick);
    btSets.addEventListener(MouseEvent.CLICK,onSetsClick);
    function onSetsClick(Event : MouseEvent) : void
              if (filme != "sets.swf")
                          filme = "sets.swf";
                          carregaFilme("sets.swf");
    function onHomeClick(Event : MouseEvent) : void
              if (filme != "home.swf")
                          filme = "home.swf";
                          carregaFilme("home.swf");
    function onHomeDown(Event : MouseEvent) : void
              btHome.y += 1;
    function onHomeUp(Event : MouseEvent) : void
              btHome.y -= 1;
    function onSetsDown(Event : MouseEvent) : void
              btSets.y += 1;
    function onSetsUp(Event : MouseEvent) : void
              btSets.y -= 1;
    function onVivoDown(Event : MouseEvent) : void
              btVivo.y += 1;
    function onVivoUp(Event : MouseEvent) : void
              btVivo.y -= 1;
    Now this is the sets.fla file:
    Here is the code for sets.fla
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    var video:Video;
    var nc:NetConnection;
    var ns:NetStream;
    var t : Timer = new Timer(1000,0);
    var meta:Object = new Object();
    this.addEventListener(Event.ADDED_TO_STAGE,init);
    function init(e:Event):void{
    video= new Video(320, 240);
    addChild(video);
    video.x = 80;
    video.y = 100;
    nc= new NetConnection();
    nc.connect(null);
    ns = new NetStream(nc);
    ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
    ns.bufferTime = 1;
    ns.client = meta;
    video.attachNetStream(ns);
    ns.play("http://www.djchambinho.com/videos/segundaquinta.flv");
    ns.pause();
    t.addEventListener(TimerEvent.TIMER,timeHandler);
    t.start();
    function onStatusEvent(stat:Object):void
              trace(stat.info.code);
    meta.onMetaData = function(meta:Object)
              trace(meta.duration);
    function timeHandler(event : TimerEvent) : void
      if (ns.bytesLoaded>0&&ns.bytesLoaded == ns.bytesTotal )
                ns.resume();
                t.removeEventListener(TimerEvent.TIMER,timeHandler);
                t.stop();
    The problem is when I test it on my computer it works but when I upload it to my phone it freezes when I click Sets Anteriores button.
    Please help me with this problem I dont know what else to do.
    thank you

    My first guess is you're simply generating an error. You'll always want to load this on your device in quick debugging over USB so you can see any errors you're generating.
    Outside that, if you plan on accessing anything inside the SWF you should be loading the SWF into the correct context. Relevant sample code:
    var context:LoaderContext = new LoaderContext();
    context.securityDomain = SecurityDomain.currentDomain;
    context.applicationDomain = ApplicationDomain.currentDomain;
    var urlReq:URLRequest = new URLRequest("http://www.[your_domain_here].com/library.swf");
    var ldr:Loader = new Loader();
    ldr.load(urlReq, context);
    More information:
    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7de0.html
    If you're doing this on iOS you'll need to stripped SWFs if you plan on using any coding (ABC) inside the files. You mentioned iOS so I won't get into that here, but just incase, here's info on stripping external SWFs:
    http://blogs.adobe.com/airodynamics/2013/03/08/external-hosting-of-secondary-swfs-for-air- apps-on-ios/

  • Still Need Help with this String Problem

    basically, i need to create a program where I input 5 words and then the program outputs the number of unique words and the words themselves. for example, if i input the word hello 5 times, then the output is 1 unique word and the word "hello". i have been agonizing over this dumb problem for days, i know how to do it using hashmap, but this is an introductory course and we cannot use more complex java functions, does ANYONE know how to do this just using arrays, strings, for loops, if clauses, etc. really basic java stuff. i want the code to be able to do what the following program does:
    import java.io.*; import java.util.ArrayList;
        public class MoreUnique {
           public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = new String[5]; int uniqueEntries = 0; ArrayList<String> ue = new ArrayList<String>();
             for (int i = 0; i < 5; i++) { System.out.print((i +1) + ": "); str[i] = br.readLine(); }
             for (int j = 0; j < 5; j++) {
                if (!ue.contains(str[j].toLowerCase())) { ue.add(str[j].toLowerCase()); } } uniqueEntries = ue.size(); System.out.print("Number of unique entries: " + uniqueEntries + " { ");
             for (int q = 0; q < ue.size(); q++ ) { System.out.print(ue.get(q) + " "); } System.out.println("}"); } } but i need to find how to do it so all 5 words are put in at once on one line, and without all the advanced java functions that are in here, can anyone help out?

    you have to compare string 0 to strings 1-4, then
    string 1 with strings 2-4, then string 2 with strings
    3 and 4 then string 3 with string 4....right???Here's a way to do it:
    public class MoreUnique {
        public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            final int NUM_WORDS = 5;
            String[] words = new String[NUM_WORDS];
            int uniqueEntries = 0;
            for(int i = 0; i < NUM_WORDS; i++) {
                System.out.print((i+1)+": ");
                String temp = br.readLine();
                if(!contains(temp, words)) {
                    words[uniqueEntries++] = temp;
            System.out.print("Number of unique entries: "+uniqueEntries+" { ");   
            for (int i = 0; i < uniqueEntries; i++ ) {   
                System.out.print(words[i]+" ");
            System.out.println("}");
        private static boolean contains(String word, String[] array) {
                 Your code here: just a simple for-statement to
                 loop through your array and to see if 'word'
                 is in your 'array'.
    }Try to fill in the blanks.
    Good luck.

  • My 27" Imac (A1312/EMC2390) keeps shutting down unexpectedly with no warning or "screen of death". I replaced the power supply, reset the SMC, and zapped the PRAM, but the problem continues. Can anyone help me?

    My 27" Imac (A1312/EMC2390) keeps shutting down unexpectedly with no warning or "screen of death". So far I reset the SMC, and zapped the PRAM. I even replaced the power supply but the problem continues. My error and system logs seem unhelpful too. Can anyone help me out?

    You can get a shutdown like that if the computer gets too hot. Make sure the air intakes on the bottom and the exhaust vent on the top are clean and are not blocked by something in your workspace like papers or the back of the computer being too close to part of the furniture. You need a good six inches (15cm) of clearance between the exhaust slot and other objects or surfaces.
    Anti-virus/internet security software, especially the "pay for" kinds, can increase operating temps. So can third-party backup software furnished with many "name-brand" external hard drives.
    Fan motors and/or temperature sensors can fail. If you have the original grey disks that shipped with your iMac, find the on that has Apple Hardware Test (AHT) and run it. If you have a failed heat sensor or fan motor, it will detect it with an error code containing "SNS" if it's a bad sensor or "MOT" if its a bad fan motor.
    AHT instructions here:
    http://support.apple.com/kb/HT1509
    Also see if your iMac 27 falls under theis Apple Repair Extension Program:
    iMac 1TB Seagate Hard Drive Replacement Program

  • [915 Series] 915P Combo Problems.. Can anyone help Please?

    Hello everyone!
    I'm pleasured to be in contact with you, I'm from Portugal, so any errors in my english, please excuse me 
    I've bought an MSI Motherbnoard 915P Combo and there is some questions that I need your help.
    My system is:
    MSI 915P Combo 8latest 1.6 Bios version)
    Pentium 4 LGA775 3.0 GHZ
    Zalman 7700 Al-CU
    1GB Kingston PC3200 2x512 (Dual Channel, 3-3-3-7)
    XFX Geforce Nx 6200 PCI-Express (with direct power alimentation from the PSU.. is this normal?)
    Enermax 350w Noisetaker ATX 2.01 (with all stability since I've bought to my P4 Socket 478)
    160GB Seagate Barracuda SATA NCQw/8MB Cache
    Pioneer DVR-108 16x DVD+RW
    Thermaltake Shark Aluminium Case
    Integrated 5.1 Sound Solution (Azalia)
    Ok... the problem is... my computer doesn't shut Off! I've installed the Windows Xp and SP2 from new, bu when I'm choosing the option "Shut Down" win windows, the pc shutt down only 3 seconds!!!
    By the on/off button is everything ok...
    Can anyone help me?
    Thank's in advance.

    Quote from: NovJoe on 21-March-05, 20:30:51
    Check your power button connector to the mobo and see if it was fixed properly or you can try turning the connector 180 degrees around and fix it in and see if the same problem replicates.
    Next you can also try to clear CMOS.
    Check in your Power Management Options in Windows and check if there's any funny settings.
    Thank you very much NovJoe for your kind attention and help.
    Since I arrive home I'll try that.
    i've  tried the connector of the power in the board of the 2 possible way with no result.
    How can I clear the CMOS? nly with Jumpers isn't?
    And what do you mean to say with funny settings in windos? Can you be more specific please?
    Regards

  • I can't get my iphone4 to sync with itunes on Windows XP. Can anyone help me?

    Is it not possible to do this on Windows XP? 
    I turned off my antivirus, and firewall. 
    I've tried authorizing my computer, but it just sits there and and tried to connect to itunes for hours and nothing happens. 
    It won't enable home sharing.
    It won't sync my phone saying "there is a problem syncing" this iphone.  (I read somewhere to make sure you had "sync phone turned on" but I've been unable to find that on my phone in itunes or under settings, or on itunes on my iphone. 
    I'm a novice to this, I'll admit, so I have no idea what I'm doing wrong. 
    I plug in the phone.  I tunes comes up automatically and starts running all by itself.  Step 1, step 2.  Then it wants to authorize my computer, and it won't go any further. 
    If I don't plug in the phone, turn it on, it doesn't work.  If I don't plug in the phone, THEN plug it in and try it, it doesn't work.  What am I doing wrong?
    Can anyone help me? 

    The iphone will sync itunes content and pics with one computer at a time.
    Sycning to another will erase the current content from the iphone.
    Copy everything (contacts/calendars/pics/files/docs/itunes content/etc) from your old computer, or your backup copy of your old computer, to your new one.

  • IPhone 5 just stopped working with my Mercedes command system? Can anyone help?

    After 6months of making and receiving calls in my Mercedes the phone suddenly cannot see the cars command system though the car can see my iPad & iMac which are in the house and my daughters old 3GS. Neither does the phone pick up my iPad for tethering anymore (which it used to do).
    In fact the phones bluetooth will not pick up any other bluetooth device full stop.
    I've tried resetting all devices but to no avail. Can anyone help?

    Same thing just happened to me, through no instigation. Ive had my iphone 5 for a couple of weeks, working ok, came to reactivate it from sleep and got no response at all, tried plugging it in and still nothing. Found this thread and the trick worked, I'm grateful to find the post but the occurrence is disconcerting, has anyone had any recurrent problems with this? I bought my phone abroad and am going back to UK soon where I'm worried the warranty won't cover it. Considering going back to the store in case I have further troubles with this handset.
    Thanks to JDM-NZ

  • I have just upgraded to OSX 10.6.8 and now I cannot open or save PDF files from the internet. I get a dialogue box saying the QuickTime plugin has failed. I have tried to download the latest plugin but this doesn't work. Can anyone help?

    I have just upgraded to OSX 10.6.8 and now I cannot open or save PDF files from the internet using either Safari or Firefox. I get a dialogue box saying the QuickTime plugin has failed. Can anyone help?

    Is this what you downloaded: iTunes 10.7?
    When the update fails what if any error report do you get, specifically? Please do this before trying again:
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.

  • Firefox frequently 'not responding' having auto-installed version 10 yesterday. No previous problems. Have disabled all plugins and uninstalled and then re-installed Firefox several times today. Problem persists. Can anyone help please?

    Firefox frequently 'not responding' having auto-installed version 10 yesterday. No previous problems. Have disabled all plugins and uninstalled and then re-installed Firefox several times today. Problem persists making continued use of this browser very unlikely unless a quick solution is found! Can anyone help please?

    Perform the suggestions mentioned in the following articles:
    * [[Firefox is already running but is not responding]]
    * [[Firefox hangs]]
    Check and tell if its working.

Maybe you are looking for

  • Transaction code for creation of CO version

    Hi All, Can anyone please let me know whats the t-code for creating co versions for a project. SAM

  • I want to change my Payment details

    I Want to change my payment details to enable in app purchases but I forgot the answers to my 2 security questions, how can I obtain this info or reset it please help. Thank you

  • Error with Forms6i accesing Microsoft SQL Server 7

    Hello every body, this is my problem: - Forms6i - OCA 6.0.5.35 - Microsoft Sql Server 7.0 I can access to SQL Server database with Oracle SQL*Plus release 8.0.6.0.0 with no problem. But developing a form when i try to create a new data block with the

  • How to make a field of ALV Grid to use a Search Help?

    Hi; I have a ALV grid with a field catalog. Say the field is 'USR000'. F4availabl = 'X' . for the field in the field catalog. I have prepared search help named ZEV_PROTYPE that uses tha table ZEV_PROTYPES.(two fields in the table :ProType and Text).

  • Verifier question

    I'm trying to figure out a detail of the verification algorithm. I created the following method by hand: public static void main(java.lang.String[]); Signature: ([Ljava/lang/String;)V Code: 0: iconst_0 1: istore_1 2: aconst_null 3: astore_1 4: nop 5: