True or false game problem

hey all, its me, the java noob!
i've been trying to make a true or false game in which the user has to do the obvious with two of the buttons and press go to start the whole thing.
however, my program has seriusly gone fooba, it says the wrong wrong answere statements, it jumps to another question whe i give an answere and soemtimes says i'm wrong when i'm not. what am i doing wrong?
i'm seriusly confused about what i did wrong. here's the code:
import java.util.Random;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.FlowLayout;
class TF extends JFrame implements ActionListener{
     public static void main(String args[]){
          new TF();
     int otherNum = 0;
     int TFnum = 1;
     JButton t = new JButton("true");
     JButton f = new JButton("false");
     JLabel tf = new JLabel();
     JButton BUtton = new JButton("go!");
     public TF(){
     setDefaultCloseOperation(EXIT_ON_CLOSE);
     setLayout(new FlowLayout()) ;
     add(tf);
     tf.setVisible(false);
     add(BUtton);
     BUtton.addActionListener(this);
     add(t);
     t.addActionListener(this);
     t.setEnabled(false);
     add(f);
     f.addActionListener(this);
     f.setEnabled(false);
    pack();
    setVisible(true);     
     public void actionPerformed(ActionEvent e){
     if(e.getSource() == BUtton){
          t.setEnabled(true);
          f.setEnabled(true);
          tf.setVisible(true);
          BUtton.setEnabled(false);
    int tfr = new Random().nextInt(10) + 1;
     switch (tfr) {
     case 1:
     TFnum = 2;
     otherNum = 1;
     tf.setText(" chess was first invented in India");
     break;
     case 2:
     otherNum = 2;
     TFnum = 0;
     tf.setText("Calvin and hobbes were both names of people in the past one was named Jhon Hobbes and the other named Thomas Calvin t/f");
     break;
     case 3:
     otherNum = 3;
     TFnum = 2;
     tf.setText("a microphone needs a windscreen which is usually made of polyster t/f");
     break;
     case 4:
     otherNum = 4;
     TFnum = 0;
     tf.setText("octopus's ink squirt is a good defense, however, the smell the ink lets off creats a direct path towards the octopus t/f");
     break;
     case 5:
     otherNum = 5;
     TFnum = 2;
     tf.setText("Monty Python and the holy grail planned to have a sequal in 1990, but that idea was posponed t/f");
     break;
     case 6:
     otherNum = 6;
     TFnum = 0;
     tf.setText("the molecules of water are structiored so that the o is in the middle and the 2 H's are either sides at 180 degrees. t/f");
     break;
     case 7:
     otherNum = 7;
     TFnum = 2;
     tf.setText("the famous series Doctor who first started in 23 November 1963 t/f");
     break;
     case 8:
     otherNum = 8;
     TFnum = 0;
     tf.setText("the oldest known dice is 5500 years old and was found in russia, it was made from the hoof of an animal t/f");
     break;
     case 9:
     otherNum = 9;
     TFnum = 2;
     tf.setText("the yumi longbow was designed to be easilly fired from horseback t/f");
     break;
     default:
     otherNum = 10;
     TFnum = 0;
     tf.setText("Albert Einstien invented the first laser, albeit only a maschine which caught and concentrated sunlight.");
     break;
     if(e.getSource() == t) {
          t.setEnabled(false);
             f.setEnabled(false);
        if(TFnum == 0) {
             t.setEnabled(false);
             f.setEnabled(false);
              if(otherNum == 2){
               tf.setText("you lose, it was Jhon Calvin and Thomas Hobbes (I switch names around)");
              if(otherNum == 4){
               tf.setText("you lose, the ink blocks all sense of smell");
               if(otherNum == 6){
               tf.setText("you lose, the H's are at 104.45 degrees, so nearly a triangle shape");
              if(otherNum == 8){
               tf.setText("you lose, actually, its 5000 years old and was discovered in eastern Iran as part of a backgammon set");
              if(otherNum == 10){
               tf.setText("you lose, he set the principal but never invented it.");
         } else {
         tf.setText("you win!!!");
    if(e.getSource() == f) {
        t.setEnabled(false);
             f.setEnabled(false);
    if(TFnum == 2){
      tf.setText("you lose");     
      } else {
      tf.setText("you win");
  }i get absolutely no error messages but everything does exactely what its NOT meant to do
if you help me : THANK YOU VERY MUCH !!!!! :)

well, it vary's, but the overall picture is that when i get
A) the true button when its false, it gives a Random answere instead of the one i need e.g. when i say that Einstien did invent the first laser (which is bollucks) it says "you lose, the anlgles at which the H's stand to the o is 104.45 degrees" which is not whatits meant to do because that was the answer for a chemical question.
B) when its false and i click false, it goes perfect!
C) when i click true and it is true,it goes completely and uterly mad and tells me some sort of "you lose" statement.
hope that helps

Similar Messages

  • True Or False Game

    Hi all
    A total newbie to director and need some help as i'm really
    stuck,
    For part of my college work I am trying doing a True or False
    game based on 10 questions but unsure how to script this, what game
    involves is when a question has been answered correctly the user is
    sent to a marker named "Right", showing an animation telling them
    they have answered it correctly, if they have answered the question
    incorrectly they get sent to another marker named "Wrong" again
    showing an animation telling them they have answered incorrectly.
    The way I have decided to do this is by importing the
    questions from text file that hold 10 question, the current script
    i have for Director to load the questions is.....
    on mouseUp me
    openAndReadText
    end
    but wanting to randomize them.
    I also have 2 buttons named True and False, and because 5
    questions are true and 5 are false, the only code i have so far in
    different scripts is
    on startMovie
    Answer
    end
    on Answer
    global gQuestions
    gQuestions = True
    end
    global gQuestions
    on mouseUp me
    if gQuestions = True then
    go to "Right"
    else
    go to "Wrong"
    end if
    end
    and dont know what code i needs to be added to determine
    which correct answer goes to the correct marker
    Thanks ifor any help in advance
    Chris

    Consider the low tech aproach.
    If you don't have a big library of questions that have to be
    imported
    dynamically, I would suggest going with a less programatic
    intensive
    approach, in which each question is contained in a predefined
    text
    member displayed in a separate score marker.
    Again the simplest least programatic approach would have the
    actions for
    the True False answer buttons assigned separately for each
    individual
    question, that is in question number 3 you might have the
    True button go
    to the wrong marker.
    You could avoid writing any lingo code by using the navigate
    to marker
    behavior from the library palette to access a marker from a
    series you
    already have setup in the score.
    A hard coded series of markers might look like:
    question1
    right1
    wrong1
    question2
    right2
    wrong2
    question3
    right3
    wrong3
    They would all show up in the parameter popup menu in the
    behavior.
    A score script at the start of the right wrong markers could
    increment
    the global question tally
    on exitFrame
    global rightCount, totalCount
    totalCount = totalCount + 1
    rightCount = rightCount + 1 -- this line is only in the righ
    marker
    script
    end

  • The case structure is not working well on comaring two strings using true or false string matching VI

    I need an execution of commands after the reply from the instrument matches with the string I provided for that i used true or false string match VI on which the true string the matching command and the string is the reply from the instrument. And I put the further executionable commands in frame after frame of sequence loop in the true of the case structure. Amd finally I given all the output strings to the concatenate string to get all the replies as one loop. But when I execute the program the desired result is not available. So kindly please help me to overcome this problem.  
    Attachments:
    basic serial with changes.vi ‏24 KB

    You VI makes absolutely no sense and I would recommend you start with a few simple LabVIEW tutorials before trying to tackle this.
    What is the point of the FOR loop with 1 iteration, it might as well not even be there, same difference.
    Why is there an abort primitive in the FOR loop, this mean the program will unconditionally stop abort before any downstream code will ever go into action. The program will never get past the FOR loop.
    You created a circular data dependency and LabVIEW inserted a feedback node automatically, making things even worse. (see also)
    You need to learn about dataflow, execution order, and data dependency.
    You need to learn about the various types of tunnels (plain, autoindexing, etc.)
    There is a tremendous amount of duplicate code. Large code sections are the same, differeing only by a string. You should only have one copy of that code inside a proper state machine. Have a look at the design templates and examples that ship with LabVIEW.
    LabVIEW Champion . Do more with less code and in less time .

  • [Help plz]Can't set a boolean attribute to true or false

    Hello,
    I'm new in NWDS development. I need to develop a download functionality
    I used a FileDownload UIElement for that and I created a node context (ExcelExport) with 3 attributes :
    - ExcelFile
    - ExcelIcon
    - And ExcelEnabled (Boolean type)
    My problem is that everytime I try to set the attribute ExcelEnabled to true or false, it return me a java.lang.NullPointerException
    I'm binding this attribute with "Enabled" property of the UIElement.
    Have anyone got this error before? Thanks a lot for your help.
    Kind regards,
    Safae.

    Hello Safae,
    Have you tried to put true/false value for the enabled property? I mean without using a context attribute?
    Also try to create the attribute out of the node.
    Regards,
    ImaneA.

  • Can we save a True or False state in Labview?

    I'm using Labview 4.01 and I'm trying to control my testing process. In
    this case, I have 3 gas cylinders and every one of them can be turned on
    or off through the digital out lines. After one tank is empty, I can
    turn it off and turn on another one. My question is, how we can save
    this status either it's true or false so next time, we can open the
    other one instead of this empty one. After this one is turned off, I can
    show its state with an indicator, but the program can not read an
    indicator, so we still can not check the state of this tank. Any one
    have a solution for this problem?
    Thanks in advance,
    Guangde Wang

    Guangde Wang wrote:
    >
    > I'm using Labview 4.01 and I'm trying to control my testing process. In
    > this case, I have 3 gas cylinders and every one of them can be turned on
    > or off through the digital out lines. After one tank is empty, I can
    > turn it off and turn on another one. My question is, how we can save
    > this status either it's true or false so next time, we can open the
    > other one instead of this empty one. After this one is turned off, I can
    > show its state with an indicator, but the program can not read an
    > indicator, so we still can not check the state of this tank. Any one
    > have a solution for this problem?
    >
    > Thanks in advance,
    >
    > Guangde Wang
    Your version is too old. So I believe that saving data in any kind of
    configuration file will
    do the job (like .ini or .conf).
    It also depends on if you are closing application between your vi runs.
    If you don't remove the vi from memory, you have a chance to use global
    or functional global to store your state.
    In latest versions you can do it another way.
    Sergey Krasnishov
    Automated Control Systems
    National Instruments Alliance Member
    Moscow, Russia
    [email protected]
    http://acs.levsha.ru

  • Check True or False Condition

    All,
    In my Form_Load module, I use For Loop to get data from Microsoft Access database to the texbox and that works fine.  The problem I have is that there is one column with True/False condition in the access database and I would like to know how to check
    if it is set to True or False.
    In the For Loop I use something like this for the textbox:
    Textbox1.text = row.cells("columnname").value.tostring()
    How do I check the column with the True/False condition
    VS 2008
    OS: XP
    Thanks,
    LA_Bob
    

    Hello,
    Thank you for your post.
    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    If you are doing your code using visual basic, Visual Basic forum within Visual Studio Language Forums:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages may help you.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • True or False

    Hi,
    My question: In my vi there are three terms (for example LEDs), which give my true or false and now the problem is that if one, two or all three give me a false something should happen, but there is only the possibility to connect two wires at the and/or functions. I wish to get a short message that something went wrong with one, two or all three terms, if the vi is finished. If everythiny is true, it´s OK, but if not i want to know it.
    Has anybody an idea?!
    Thanks, Thomas

    Maybe something like this?
    Message Edited by altenbach on 09-28-2007 10:40 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Count-ON-LEDs.png ‏10 KB

  • Bug Report: enum metadata containing 'true' and 'false' string values not displaying unless "goosed"

    I have metadata whose value is 'true' but the corresponding enum title is not being displayed. If I set it explicitly to 'true' it will be displayed even though the value is the same as it was.
    Likewise for 'false'.
    I do not have this problem with enums that have any other string values i.e. 'yes' and 'no' function properly, but 'true' and 'false' do not.
    Rob

    Due to better understanding on my part, and the fixes in Beta 2.2, the
    issues raised in this thread are put to rest.
    Abe White wrote:
    >
    We'll investigate further. Stay tuned...
    "David Ezzio" <[email protected]> wrote in message
    news:[email protected]..
    Abe,
    Actually, it doesn't make sense. The first iteration shows
    jdoPostLoad is called just prior to using the fields of Widget and Box.
    After the commit, the instances are not cleared. So far, so good.
    In the second iteration, we see that jdoPreClear is called, but
    jdoPostLoad is not called. Yet the values are there for use during the
    call to Widget.toString() and Box.toString() within the iteration. How
    did that happen?
    On the third iteration, now the value of name is null, but last we
    looked it was available in the second iteration. Other than that, I
    agree that the third iteration looks ok, since it is being cleared and
    loaded prior to use. But in the jdoPreClear, the values should be there
    since the values were used in the previous iteration and are not cleared
    at transaction commit due to retainValues == true.
    David
    Abe White wrote:
    David --
    I believe the behavior you are seeing to be correct. Section 5.6.1 of
    the
    JDO spec outlines the behavior of persistent-nontransactional instancesused
    with data store transactions. As you can see, persistentnon-transactional
    instances are cleared when they enter a transaction; thus the calls to
    jdoPreClear. When the default fetch group is loaded again (like whenyou
    access the name of the widget) a call to jdoPostLoad is made.
    You are seeing the name of one instance as 'null' in the third iterationof
    your loop because the instance has been cleared in the second iteration,and
    the jdoPreClear method is not modified by the enhancer (see section10.3).
    Make sense?

  • Lot of returns on Playbook according to Futureshop tech. ? True or False ?

    Hi,
    I'm in Quebec city,
    According to a FutureShop tech. "1 of 2 Playbook sold are returned " ? "A lot more than other tablet"...
    True or False ? 50% ?
    What are the reason of return ? 
    He also told me "Playbook hardware is cheap"...
    I don't think so, I think that RIM is making good product.
    His friend, who work at BestBuy as seller, says the same.
    I'm the proud owner of a PlayBook, never had problem, and I don't hesitate to recommend it to my friends.
    So what's the truth ?  Thanks.

    Ha, you are not alone. I am annoyed by RIM-bashing also.
    It seems a popular sport of late, but as is usual, it normally comes from those immature people with some other inadequacy  in which they feel putting another down makes them feel greater.
    But I am also annoyed by mosquitoes and arrogant people the same, and 10,000 years, nothing has kept either from multiplying.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Where do I find the TRUE or FALSE boolean value?

    I'm doing a program that displays the operation of global variable. I'm suppose to put a TRUE or FALSE boolean value and I can't find it. Please help.

    You can't find an indicator for the front panel or you can't find a Boolean constant to put on your diagram? You've got Boolean palettes for both front panel and diagram. Everything you need should be on one of the palettes. If that's not it, could you explain your problem in greater detail?

  • Applescript help with true or false script

    I'm in need of a applescript that will run two different scripts based on the outcome of an existing file.
    I have a folder called Status. Inside this folder is a simple text file called Good.rtf
    I would like a script that would run one or the other script base on the true or false output.  If file exists then:
    true will
    run script A
    false will
    run script B
    I have been searching the web for two days looking for something to help me get started on this and have not had much success.
    Please help me.   I really would appropriate any help or guidance. 
    Thanks....
    Ron

    Ron
    AppleScript calls this kind of script a "Conditional" = if this > then that
    Some templates are in MacintoshHD/Library/Scripts/Script Editor Scripts/Conditionals
    You don't need a value for "false" in binary as it is merely "not true" (else)
    if true then
        -- insert if actions here
    else
        -- insert else actions here
    end if
    If you already have your Scripts A & B working, copy>pastethem into the "insert actions here" part as appropriate
    ÇÇÇ

  • Parameter Query for True or False values

    I have what seems like a painfully simple task and it has me stopped dead.  I reviewed a similar thread, and the answers there don't seem to apply. Working in Crystal 11.5 with an MS SQL database.
    I am pulling data from vwCommmittees.  There is a field in this view called IsActive.  I want to create a committee list report that will allow the user to select only the active committees or all committees.
    A SQL select statement that says where dbo.IsActive = '1' will return only the active committees.
    In Crystal reports, if I place the IsActive field on the report, it returns with "True" or "False."
    When I create a parameter for this field, I find that 1) I can't see the parameter in the report expert -- my only choices are Is any value, Is true, Is false or Formula.
    I've made several attempts to create a formula and nothing is working. It's not clear to me wheter I should be creating a static or a dynamic parameter.  When I choose boolean as the type, that doesn't seem to help.  I tried a dynamic parameter which gave me true and false values, but don't seem to work.
    Any pointers on dealing with this kind of parameter query would be greatly appreciated.
    Sincerely,
    Ridge (in New Joisey)

    Hi..
    Create a static parameter and give the default values like
    0 and 1
    In Record Selection check like..dbo.IsActive = {?parameter}
    If the above is not working for you, then create a formula
    like..
    If dbo.IsActive = '1' then
    "Active"
    Else "In Active"
    Place this formula on your report and create a static parameter with default values Active and In Active.
    In record selection filter the above.
    Thanks,
    Sastry

  • Titanium Fatal1ty Pro SPDIF game problem

    (Titanium Fatalty Pro SPDIF game problem hi all,
    sorry if this issue reported in the past i but i could not get any answer on any relati've posts, the terminology was so complicated
    i buy?a new pc with a Titanium Fatalty Pro sound card, i use Vista sp2 x64, the sound card is connected to my external amplifier with SPDIF out in order to get surround sound for my movies and my games and here is my problem
    any movies format with surround sound play perfect with out any problem any kind of movie DVD, dvix, mkv?files?etc
    but non of the games i play?use the surround system, why is that? is any?kind of special settings needed to be done? how is possible to get surround to movies and not to the games?
    thanks you all for your time ?

    ,Re: Titanium Fatalty Pro SPDIF game problem? this is really coincidence - I just posted on the very same topic 5 minutes ago.
    for games just go to the Console Entertainment mode > Encoder > Dolby Digital. Although this is not documented I believe what happens is that the sound card encodes the 6 digital channels onto Dolby Digital mode and transfers this over SPDIF. Kok-Choy actually recommend using the standard analogue cables (and he has a point as you are actually upcoding an existing game signal onto Dolby so that your digital receiver can then decode this down to 6 channels - seems a pretty useless overhead)
    for video - I am curious to know what you do - I can either get 96/24 bits on the display of my z5500 with a direct signal but the z5500 receiver then tells me that this signal is only in dolby ProLogic II (and not DD or DTS). As alternati've I use again the encoder and have to select for EACH FILM WHAT IS BEST DOLBY DIGITAL OR DTS. Pls explain what settings you use.
    thanks

  • How to set render true or false in java class

    Use case:
    i have a page in which i have one inputListOfValues attributes and two LOV .initial the LOV render attribute value is false .it means it show only one attribute in run time .inputListOfValues is content two value .suppose if first value A then the first LOV have to show and is it value is B then Second LOV have to show .i bind my LOV to class .but i do not know how to set render attribute at java class.

    <af:inputListOfValues label="Branch Name"
    popupTitle="Search and Result Dialog"
    id="ilov1"
    model="#{pageFlowScope.organizationLOV.param['bindings.Organization'].listOfValuesModel}"
    converter="#{pageFlowScope.organizationLOV.param['bindings.Organization'].convert['latinDesc']}"
    valueChangeListener="#{viewScope.salaryBenefitsReportForm.branchChange}"
    binding="#{viewScope.salaryBenefitsReportForm.branchName}"
    rendered="true" visible="false"/>
    <af:inputListOfValues label="Department Name"
    popupTitle="Search and Result Dialog"
    id="ilov2"
    model="#{pageFlowScope.objectLOV.param['bindings.Department'].listOfValuesModel}"
    converter="#{pageFlowScope.objectLOV.param['bindings.Department'].convert['latinDesc']}"
    valueChangeListener="#{viewScope.salaryBenefitsReportForm.departmentChange}"
    binding="#{viewScope.salaryBenefitsReportForm.departmentName}"
    rendered="true" visible="false"/>
    this is code in jsff .
    and class code are following
    public void reportBy(ValueChangeEvent valueChangeEvent) {
    String value=(String)valueChangeEvent.getNewValue();
    System.out.println(value);
    if(value.equals("Branch")){
    branchName.setVisible(true);
    departmentName.setVisible(false);
    AdfFacesContext.getCurrentInstance().addPartialTarget(branchName);
    AdfFacesContext.getCurrentInstance().addPartialTarget(departmentName);
    if(value.equals("Department")){
    departmentName.setVisible(true);
    branchName.setVisible(false);
    AdfFacesContext.getCurrentInstance().addPartialTarget(departmentName);
    AdfFacesContext.getCurrentInstance().addPartialTarget(branchName);
    }

  • Is this TRUE or FALSE ?

    Hi all,
    Pls tell me whether this sentence is true or false.
    A transaction used by a BMT bean MUST have been started by the bean.
    In book this question is marked as false, but as far as I think it should be true.
    Pls update.
    Regards,
    Sanjeev

    As it's written I would say it's true as well.
    Bean-managed transactions are only allowed for session beans(stateful and stateless) and message-driven beans. Furthermore, if there is any client transaction context propagated on the call to the BMT bean, the container is required to suspend the client tx before calling the business method. So, BMT beans cannot inherit client transactions.
    For BMT stateless session beans and message-driven beans, there cannot be an active user transaction when the business method completes. If there is, the container is required to treat it as an error.
    The slightly more interesting case is for stateful session beans. For BMT SFSBs, it's o.k. for the transaction to still be active when the business method returns. In that case, the container suspends the tx and assoicates it with the SFSB. Whenever the SFSB is invoked again, the previously associated transaction is resumed before the business method is called. ( The same rule holds for client transactions. If there is one, it will be suspended and resumed when the business method completes. ) However, even if the container resumes a previously suspended transaction before invoking the SFSB, it can only be a transaction that was started by that bean.
    --ken

Maybe you are looking for

  • How to check number of rows processed in a package

    i have a pakage wid at least 11 procedures which runs on running a report now user run the report and he told me that records are not fully processed records are less so how to check how many records are processed so i can conform the data its urgent

  • Using class from one application in another application

    How can I use a class deployed as part of an application in another application withour putting the jar files in the classpath? For example, there two application deployed: app1 and app2. An EJB in app1, app1_ejb1, uses an class, app2_class1. In orde

  • Adobe CC/CS6 - Error 16 and no SLStore or PCD File

    Hey all, i was wondering if the Adobe community could help a guy out. My problem is regarding Adobe CC/CS6 on Mac OSX. I have had CS6 for about 2 years and all the apps have worked fine up to now. Yesterday, 3rd Feb 2015, i tried to open photoshop (a

  • Change Event Name in iPhoto for iOS

    I've bought in to Apple's promise of the "PC free" lifestyle with an iPad and the camera connectivity kit. A major problem is the fact that you couldn't manage events on the iPad with the standard "Photos" app. With the new "iPhoto for iOS", will I f

  • How to display BLOB images from the Oracle database within Crystal

    Let's say a have the following table IMAGES ======== DOC_ID NUMBER DOC_NAME STRING DOC_IMAGE BLOB The BLOB field can have any type of document: PDF, email, WORD, EXcel, etc. I would like to present the DOC_ID and DOC_NAME and let the user click any o