Having more then one class

Right i'm trying the write the game Mastermind (if you have not played it or know what i'm on about heres a web site with the game on http://www.irt.org/games/js/mind/) Right so far its going pretty well, but i was talking to a friend who told me i should not just have one big class, so i'm having a go at useing class's , buts it not going very well. I'm trying to make the part of the program which random selects the colours in to one class and the rest of the program as another for the time being. Heres the code:
/// MasterMind1
import javax.swing.*;
public class MasterMind1 {
  public class Random {
    private static void Random(String args[]){
    int [] test;
    test = new int [4];
    String guess;
    int [] randomNumber;
    randomNumber = new int [4];
   for (int i=0; i < randomNumber.length; i++)  {
         randomNumber[i] = (int)Math.floor(1 + (8 * Math.random()));
         System.out.println("no is " + randomNumber);
} // end for loop
test[0] = randomNumber [0];
test [1] = randomNumber [1];
test [2] = randomNumber [2];
test [3] = randomNumber [3];
//end class Random
public class void main (string arge[])
guess=JOptionPane.showInputDialog ( "Enter integer" );
playerGuess[0] = Integer.parseInt(guess);
guess=JOptionPane.showInputDialog ( "Enter integer" );
playerGuess[1] = Integer.parseInt(guess);
guess=JOptionPane.showInputDialog ( "Enter integer" );
playerGuess[2] = Integer.parseInt(guess);
guess=JOptionPane.showInputDialog ( "Enter integer" );
playerGuess[3] = Integer.parseInt(guess);
for (int i=0; i < test.length; i++)
if (test[i] == playerGuess[i] )
JOptionPane . showMessageDialog ( null, " Well done " +playerGuess[i], "hello",
JOptionPane.PLAIN_MESSAGE );
else
JOptionPane . showMessageDialog ( null, " Your wrong " +playerGuess[i], "hello",
JOptionPane.PLAIN_MESSAGE );
if (test[i]==playerGuess[i]){
pico [i]=2;
test[i] = 0;
playerGuess[i]=0;}
for (int i=0; i < test.length; i++){
if (test[i] != 0);
for (int k=0; k < playerGuess.length; k++){
if (playerGuess [k] != 0 )
if (test[i] == playerGuess[k]){
fermis[i][i]= 1;
test[i]=0;
playerGuess[k]=0; }
score [0]= fermis [0][0] + fermis [0][1] + fermis [0][2]+
fermis [1][0] + fermis [1][1] + fermis [1][2]+
fermis [2][0] + fermis [2][1] + fermis [2][2]+
fermis [3][0] + fermis [3][2]+ fermis [3][3];
score [1] = pico[0] + pico[1] + pico[2] + pico[3];
System.out.println (score[0]);
System.out.println ( score[1]);
System.exit( 0 );
}// end main
When i try to compill it just comes up with errors i'm not total sure why, mind you not sure what i'm doing anyways so its a bit hard to tell what i've done wrong. The way i've set the class's is it right? Also the Array with the random colours are in the 1st class, in the 2nd class do i need to do anything speical or does it not matter which class you make the array any class can see it and use it, even if its private?

The basic structure of a class is something like this, but do have a look at the tutorials.
public class SomeClassName {
        //Declare some member variables
        int i;
        Player player;
        //Declare some methods
        public int returnAValue(){
                //Write some method code
        public static void main(String[] args) {        
                //You don't need a main
                // But if you have one it must have the above signature.
}   // end class
            

Similar Messages

  • OVI and syncing and having more then one phone

    I recently just upgraded my wife and my phones to Nokia 6350's, after backing up all my contacts and everything in Nokia's PC suite from the old phones and after activating the phones and restoring the back up to the new phones I saw there was an update suggestion to the PC suite which was OVI.
    I thought great maybe more function Etc..
    After downloading and finally figuring out how to put my phone number in in international format, I get it registered logging into my wife's phone first, from inside the app, I added my phone to it, but it didn't as me for the phone number or anything, but allowed me to change from one phone to the other, well when I hit the sync button for my phone it connected to my phone then added all my contacts to the existing contacts of my wife's, what I didn't relies at first it also put all my wife's contacts into my phone book on my phone, this is a major bug that shouldn't be allowed, Why would I want my wife's contacts in my phone???
    Well lucky for me since I had just backed up all my contacts separately,
    I closed out OVI and started PC Suite up, I wiped out my whole contacts and reloaded them from back up,
    What I can't figure out is why would they design their program like this that doesn't seen to allow you to manage multiple phones from the same program,
    Nokia's PC suite does this part great, as it keeps each phone totally separately.
    The other thing I don't care for is that OVI seems to depend on having an internet connection, which there are people out there that would like to manage their phones without having to have this, PC suite can be used without a internet connection.
    Does anyone have any idea on how to separately manage more then one phone in OVI?

    Set up a user account in Windows for your wife on the same computer and when syncing her phone set up and run Ovi Suite from that account.
    It is easy and once one gets used to it it gives great flexibility.
    This is not just a Nokia thing but quite a normal way of managing multiple devices for multiple users in Windows applications (e.g. we use an application that remote controls multiple telecommunications devices for multiple users and it manages them in that same way except it goes further and requires a separate account for each device as well as each user).

  • Having more then one tab open causing firefox to hang

    When I have facebook,TWIT live video running and have more tabs open and switch from TWIT live video to Facebook or another tab it start to hang on me and I can't get to any tabs. I have to go to Windows Task Manager and it say not responding and have to end Firefox 4.0. Beta 6.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Is anyone else having more then one problem with this phone? (BBSTYLE)

    I've always wanted a blackberry phone, and  about 4 months ago I finally did. 
    Purchased a brand new blackberry style, I was very excited about this purchase. 
    Anyways, the first 2 weeks were great, then all these problems started to happen..  
    Since then every month a new problem occurs. 
    -the phone freezes. (a lot)
    -the internet (while refreshing or what I like to call it "thinking") completely closes, and erases everything. 
    -While using the phone for a call the back of the phone( where the battery is) heats up, to the point where it is too    hot to handle. 
    - the track pad, gets way to sensitive then gets all crazy on me when IM scrolling up or down on a website, or in a text message. 
    - the wifi does not even want to try and connect. 
    - then, just recently, i'm not receiving some texts, and missing very important calls.
    I'm seriously unhappy, because the knowledge  I have about blackberry products (and what it says on the outside of the box) is that this phone is for the busy business person, and I have to wait ten minutes for the phone to start acting right to put in a contact in the address book. 

    I just bought this phone seven months ago (swapped out a different BB model for "Style", and I'm still unhappy), and it freezes up ALL THE TIME now.  It'll freeze up for days on end. I can't live like this anymore.  The tech support group said that they'll have to "restore it to factory settings", meaning I'll lose ALL the data I have stored, including all the notes, info, on my Notes Pad under Application. If the phone ever allows me to get to that icon again, I'll have to transfer all of that data to my desktop before I allow them to restore it to factory settings.
    But the real issue is is that THIS SHOULD NOT BE HAPPENING in the first place.  They make absolutely no apologies for it. I'm reading here that SEVERAL models have the problem of freezing up.  This is the last time.  When my contract is up, I am DEFINITELY switching to a Galaxy IIS.  This is no way to deal with a supposed "smartphone".  Research in Motion should be issuing new phones to EVERYONE for the trouble they're causing.  The blue cursor/whatever will NOT travel down to the buttons, so, I can't access ANYTHING  on my phone. I can't get to contacts, I can't get to my emails, nothing.  I have to repeatedly hit the BlackBerry icon, and get to certain areas completely backward, but it's still not functioning 1% of what it should be.  I can't scroll around anywhere...not up and down my inbox, on the home page, nothing.  What the hell is wrong with them?  Don't they do any product testing???  I'm  in marketing, and this company, and their products, SUCKl.
    If anyone has any advice other than remove the battery and pop it back in after X amount of time, let me know.  I've had the battery out for one minute as well as overnight....the phone has stopped now for 55 hours, and I'm sick of it.

  • If my component has more then one button,how to create click events

    I am learning about java beans
    My java class
    public class ButtonClass extends JButton implements Serializable{
    // ButtonHandler bh;
    public ButtonClass() {
    setText( "Hello world!" );
    setOpaque( true );
    setBackground( Color.ORANGE );
    setForeground( Color.BLUE);
    setVerticalAlignment( CENTER );
    setHorizontalAlignment( CENTER );
    // addActionListener(new ButtonHandler(new JTextArea("Hello")));
    But i want to create Bean having more then one button on my bean.
    But how to create event individually for each button

    Do you mean how do you process each event from the buttons and know which button casued the event?
    If that is what you mean then look at ButtonGroup. You can add the same mouselistener to each button and then check which one cause the event:
    myButtonEvent.getButton()

  • How can I restrict more then one user to access the table?

    Hi !
    I have a problem and two solutions and I am a bit confused as to
    which one is the best one and/or can there be any better way of
    handling the problem ?
    Problem : I have to update a key field of a table when I update
    it in the form 5.0 screen. I am basically doing a maintenance of
    a table and if a certain field is updated then the change has to
    be reflected in two more tables. But the issue is that the field
    is a part of the key in those two tables. So all I can think of
    is that I need to insert new set or rows for that new value of
    the field and delete the old set of records for old values of
    the field.
    There are two ways of doing it;
    1.One option can be to explicitely define two cursors separately
    and fetch the values in them one by one and then insert the new
    records and then delete the old records in both the tables. This
    I feel will be a cumbersome process both in terms of processing
    time and the coding.
    2.Second option I was thinking can be to create two flat tables
    (without keys) and insert the values in them and update the
    changed field there and then insert the rows in the respective
    tables. Delete the old records in the main tables and delets the
    records in these flat tables. This is a bit more faster and
    easier to predict and code. This seems to be a better option for
    me.
    Any comments on these ?
    In both the cases I was thinking of making some provision so
    that more then one person can't update the table simultaneously.
    Since if there are more then one persons doing the processing
    then some inconsistency might creep into the whole process.
    This is easier to do in the second process as if I check the
    data in the flat tables and if there is some data then I can
    presume that some one is doing the processing and I can ask the
    other person to hold for a while. But in this case how can I
    stop more then two people to simultaneously check for the empty
    table and start inserting the record ?
    I was just thinking of having a sepatare table having only one
    field and this will be a key field and as the process begins the
    process will insert a fix value say 'Y' in the key field and at
    the end of the process the record will be deleted and this way
    we can restrict the user to access the process more then one at
    a time..? Since you can't have same value of the key in a table
    more then once.
    Any better way of handling it will be deeply appreciated.
    How about locking the table at the begining and releasing the
    lock at the end ? Will there be any issue in that? since I am
    inserting and deleting the rows in the same transaction.
    Comments welcome,
    Shobhit
    null

    How about performing the update IN the database using a stored
    procedure?
    By using non-database fields on your form to get the
    information, you can then call the procedure in the database to
    perform the updates. If an error occurs in the procedure you
    rollback, if necessary, and send a message or status back to the
    form. If it succeeds you might wish to commit and then re-
    execute the form's query -- using either the original key values
    or the new key values...
    null

  • Is there a way to Search (List search) for more then one field text from a column for Bulk uploading?

    I've been trying to find more information on this and I apologies if this has already been answered. I just don't know the correct way to ask this. We have a SharePoint List at the company that we have people input information into different columns. The
    problem is most of those information are very repetitive. Is there a way for me to search more then one field text in the column and just input that same information in?
    ex:
    Column 1
    Column 2
    Date:
    883851
    MidWest
    User input 
    8831518
    MidWest
    User input
    On the search field in the SharePoint List, I would need to search for 883851, 8831518 etc,  would view those requested numbers, then I would click edit and change dates to those rows. Does that make sense? I'm sorry I'm fairly new at sharepoint.

    I think what you're asking is about having repetitive options in a list, show up easily for new items being created.
    This can be done by setting the columns that contain repetitive information to Choice fields.  In the configuration of the Choice field, check the box for "Allow custom values".  Now as users are entering data into the list, the dropdown of options
    for a given field grows and users can quickly see and select previously entered and thus repetitive values for the given fields.
    I trust that answers your question...
    Thanks
    C
    |
    RSS |
    http://crayveon.com/blog |
    SharePoint Scripts | Twitter |
    Google+ | LinkedIn |
    Facebook | Quix Utilities for SharePoint

  • Using more then one Multitouch.inputMode on one screen

    Hi All,
    I have figure out that on one screen I am not able to work with more then one Multitouch.inputMode. As per my requirement I am having two different component on the same screen,one is using the TouchEvent and another is using GestureEvent.I am getting the issue that if I am using both on the same screen then the  GestureEvent is not firing.
    Any help will be appricated.
    Thanks in Advance.
    With Regards,
    Shardul

    Or you could use gestouch:
    https://github.com/fljot/Gestouch
    With that you can detect various gestures all in one gesture mode. It may solve your issue.

  • Using more then one table/view in same Report

    Hi,
    I am using Discoverer Plus Version 9.0.4.43.15.
    Is it possible to use more then one table/view in a report without the tables/views being joined in any way? It would be like using two different datasets in the same report without the datasets having anything to do with one another. Right now when I select items from the available tab I can only pick tables that relate to one another in some way.
    Or is it possible to use more the one table in the same report? Each table using a different query/view/table.
    Thanks

    Spence,
    try following type of query using set operator UNION / UNION ALL:
    select col1,col2
    from t1
    union all
    select col1,col2
    from t2
    If you don't have restrictions then this is the best way.

  • MVC - More then one view managed by the same contrler.

    Ok, I have been reading and searching examples on the MVC .. but all the examples show just what to do when you have just one view of the model. What I f I have the more the n one view to handle the same model.
    As we know the views would need to be registerd inside the controler? How can I do this If I have more then one view?
    does anyone have any ideas!?
    Would it still be correct if when an action occures on my view instead of the controler capturing that event an handiling, I make my view call the controler to handle it?

    So in your opinion is it ok if I call my controler from the action event of my button?
    I just did a small example below:
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    public class Starter extends JFrame{
         private Model myModel = new Model();
         private Controler myControler = new Controler(myModel);
         public Starter(){
              JButton myButton = new JButton("Test");
              myButton.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        myControler.makeAction("Hello");
              this.getContentPane().add(myButton);
              this.pack();
              this.show();
         public static void main(String[] args){
              new Starter();
    }As you can see I am calling the controler to manage the new data from the action event of 'myButton' !
    Is the above code ok with the spirit of the MVC?

  • View more then one site

    Hi, I was wondering if anybody knows how i can view more then one web site at a time instead of having to minimize or close every single time? For example, on a PC there are tabs at the bottom of the screen and you can flip back and forth between site, can a MAC do anything like that?

    Hi
    Welcome to Apple Discussions and Mac computing.
    Go to the Safari Menu (to the right of the Apple Icon in the upper right of the screen) and select Preferences. When the Preference panel opens, select Tabs (if you don't see a Tab panel, click on the small pill button in the upper right). Check all available boxes. You'll see instructions for key commands on this panel to activate different aspects of Tabs. If you want to learn more about the Tab function, go to the Safari Help Menu and type "tabs" in the Search field.
    Once Tabs is activated, a Tab Bar appears, similar to what is created at the bottom of the IE window. To create a new tab, simply press the Command and T keys. If you want to open a link on a web site in a new tab, hold down the Command key when you click on the link.
    Good way to familiarize yourself with OS X is to pick up a copy of Scott Kelby's book OS X Tiger: Killer Tips.

  • HT1495 More then one iPad being used.

    We have more then one iPad. Can we use one iTunes account so I do not have to buy games and songs more then once? Also, 3 people are on one iTunes account. How do we avoid our iMessages being shown on each device?
    Thanks.

    Yes, you can run as many devices as you want from one iTunes account.  To avoid having messages sync across all devices, use different email addresses for iMessage.

  • Bouncing more then one Track directly to CD

    Hi all,
    I finished a project and am playing with different ways of bouncing the finals (Logic Express 7.2.3). I have already bounced them all to WAV files and also to AIFF files for permanent backup. However, I noticed the "bounce to CD" option and tried this and it worked perfectly. I played them side by side and you could not tell the difference from the CD and the project played back in Logic. However, what I cannot figure out for the life of me is how to get more then one track on this CD. Once I burn Track 1 to CD (I picked write as a multi-session disc and also tried it without it) I open up track 2, hit bounce to CD and it tells me to insert a blank disc and refuses to add track 2 to the exiting CD. Nothing I do seems to let me burn more then one song to this CD. So if anyone can please help and explain how to burn multiple tracks, 1 at a time directly to the same CD I would really appreciate it, without having to purchase additional software (if possible).
    Thanks!
    Maestro2be

    The best way to do this is to bounce the tracks separately and then use either iTunes or BurnX Free to create the CD. Providing you only work with wave files (Wav or AIF), this will not result in any loss of quality.
    I tend to keep wave files of all my work on the computer anyway, for reference purposes, so it's no hardship creating a folder with my bounces in and then burning them afterwards. Beats the slightly flakey multi-session disks any day.
    Have fun!
    Pete

  • How do I get the text to flow throughout more then one page.

    Hello,
    I am currently using LiveCycke Designer to create a scholarship for my company. I created fields for the form and I would like to insert a text to describe the scholarship. When I insert the text, it doesn't flow onto the next page. I've tried creating a subform and clicking "flowed" and "allow page breaks within content". I also clicked auto-fit for the height, but it just makes a line. For the text box, I've clicked "Expand to fit on the height". It is also a dynamic XML Form. Is there anything else I should be doing?
    I could always send the file to someone to see if they can figure it out.
    Thank you,
    Natalie

    Thank you so much !
    but the link doesn't seem to work. It says that the URL is not in the correct format for an Acrobat.com document link.
    Natalie
    Date: Wed, 12 May 2010 07:53:12 -0600
    From: [email protected]
    To: [email protected]
    Subject: How do I get the text to flow throughout more then one page.
    Here is the corrected form..Even you you set the Subform type to "Flowed" to the subform where the Text box resides, you did not set the Page1 to Flowed (which is the key)..But when I make the Page1 type to "Flowed", all your fields above the Scholrship text boxes' Subform will go one below another.. To fix this, first I have select all the fields and wrap them into a subform and then set the Page1 to Flowed..
    https://acrobat.com/#d=XQ1yfV8fCk85M7sRLD*-gg
    Thanks
    Srini
    >

  • HOW DO I USE MORE THEN ONE ITUNES WITH MY IPHONE WITHOUT ERASING MY MUSIC?

    I have two different laptops with iTunes on it. I use both of them but my iPhone only works with one iTunes. I plug it into the computer and it says that my iPhone cannot use more then one iTunes. Is there a way I can use both or no?
    YES I AM CLICKING MANUELLY ADD SONGS TO MY iPhone.
    I just bought my iPhone about a week or so ago.
    Please help ASAP.

    I clone my library to a portable drive using SyncToy 2.1, a free tool from MS. I run this both at home & work so that I essentially have three identical copies of my library for backup redundacy, any of which I can use to update my iPods and my iPhone. I use iTunes Folder Watch occasionaly in case I've managed to download, for example, a podcast at one location but overwrite the library with a newer copy updated at the other. It can be done but you need to take considerable care...
    tt2

Maybe you are looking for