Click here to Skip to main content
15,890,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
not sure why, After i add public class static main(String[] args) still not compile
No main method, javafx application, applets or midlets found in file


What I have tried:

public class Die {
public static void main(String[] args)
{
    private final int MAX = 6;  // maximum face value

    private int faceValue;  // current value showing on the die

    //-----------------------------------------------------------------
    //  Constructor: Sets the initial face value.
    //-----------------------------------------------------------------
    public Die()
    {
        faceValue = 1;
    }

    //-----------------------------------------------------------------
    //  Rolls the die and returns the result.
    //-----------------------------------------------------------------
    public int roll()
    {
        faceValue = (int)(Math.random() * MAX) + 1;

        return faceValue;
    }

    //-----------------------------------------------------------------
    //  Face value mutator.
    //-----------------------------------------------------------------
    public void setFaceValue(int value)
    {
        faceValue = value;
    }

    //-----------------------------------------------------------------
    //  Face value accessor.
    //-----------------------------------------------------------------
    public int getFaceValue()
    {
        return faceValue;
    }

    //-----------------------------------------------------------------
    //  Returns a string representation of this die.
    //-----------------------------------------------------------------
    public String toString()
    {
        String result = Integer.toString(faceValue);

        return result;
    }
}
}
Posted
Updated 16-Oct-18 10:47am
v3
Comments
David_Wimbley 16-Oct-18 15:24pm    
Looks to me like you are missing a bracket between public class Die and public static void main
Jenny Jiang 16-Oct-18 15:50pm    
i added it back still no work
David_Wimbley 16-Oct-18 15:59pm    
you need to post the error you are seeing if you want meaningful help. Posting code and saying it isn't working won't get you very far.

What exception/error is your compiler giving you?
Jenny Jiang 16-Oct-18 16:46pm    
No main method, javafx application, applets or midlets found in file
Richard MacCutchan 17-Oct-18 4:12am    
Please update your question with the actual code that does not work, and show the output from the compile phase.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900