Check question using HashSet

I am trying to stop the same question from appearing again on the screen ones it has been answered. like store the last question and then check to see if it's not already been asked. . just want to no with what i have up to now am i on the right tracks or not? been told to use HashSet also.
code:
// the question being shown
String question=questionLabel.getText();
// gets the new question
String newQuestion=ClientCommunication.getRandomQuestion();
// where trying to check the the newQuestion is not already been asked
try {
HashSet questionhash = new HashSet();
questionhash.add(question);
System.out.println(questionhash);
if(newQuestion.equals(questionhash))
newQuestion=ClientCommunication.getRandomQuestion();
} catch (Exception e) {
System.out.println("Error: " + e); }
// shows the new question
questionLabel.setText(newQuestion);
answerField.setText("");
any helpful hints / tips i would be grateful
cheers chris

That can be fixed a little:
try {
  HashSet questionhash = new HashSet();
  String question = null;
  do {
    question = ClientCommunication.getRandomQuestion();
  } while (! questionhash.add(question) )
  System.out.println(questionhash);
  questionLabel.setText(question);
  answerField.setText("");
} catch (Exception e) { //catch specific exceptions rather than Exception e...
  e.printStackTrace();;
}My preference would be to make the ClientCommunication class create a Stack with random order of questions, each time a guestion is asked for pop it out of the Stack, add it to a 'read' List and return it. Return null when you reach the end of the Stack (as a signal) and then reshuffle the List and fill the Stack again. This way, once-only and random order can be controlled at the source, which IMHO is better...

Similar Messages

  • AP Checks Question

    We are beginning to look at printing signatures on our AP checks with something like Evergreen and a number of other customizations. However I would like to look into simply sending all the payment information to a Automated Clearing House (ACH) and let them handle the Checks, EFT or what every and we would not have to be concerned with signing or even printing checks.
    If any one has any experience or ideas along this line please share.

    What is your EBS version ? Have you explored printing checks on your own using XML Publisher ? It would be cheaper then using an ACH, I believe. We use this method without any special printers or stock.
    MOS Doc 312533.1 - Check Printing using XML Publisher
    MOS Doc 110406.1 - Check Printing Frequently Asked Questions
    HTH
    Srini

  • Void the check but cannot print another check by using the same check no.

    Dear All,
    Our customer need to print the check on number #10.
    However, we already print a check by using #10.
    Then I void that check and go to house bank and change the 'Next Check No.' to 10.
    But the system still print the check on number #11
    Please help. Thanks a lot.
    The other question is, when I take a look their database, I cannot find check #9. But if I would like to print check#9, the system said it is already in the database. Why? Thanks
    Regards.
    Yuka
    Edited by: Jie Jin on Jul 31, 2009 11:06 PM

    We test printing check on their production database
    So check A printed on check #10 check b#11 check #12 printed on the blank paper.
    Then they said they would like to print the real check from number #10. But the system will not allow us to do that. It ask us start from #13.
    So, they decide to write the check manually for check #10, check #11, check #12. Then they will have 3 checks in the system they didn't print it. And next time, they can start from #13.
    The problem is, for the 3 checks they write manually, the system didn't print it. So, every time, they are showing on 'to be printed' list (actually our customer write it manually). What should we do to block those 3 checks if they don't want to void it? Thanks.

  • Regd. error in sender agreement(when to check sender uses virtual receiver)

    hi Experts,
    I  am doing a file(  SFTP adapter ) to IDOC scenario.
    I got an error :
    Couldn't retrieve inbound binding for the given P/S/A values:FP=XYZ;TP=;FS=XXXX;TS=XXXX;AN=XXXXXX;ANS=;
    I checked my sender agreement  and saw some "*" symbol displayed at the end on SA name.
    To quick fix it and remove the star symbol'', i have just created SAgreement  again and this time i checked "Sender uses virtual receiver " and revomved thestar symbol '' and saved without mentioning anything there.
    When i tested it worked!  but i want to know what made it work, is it the right practice.
    i did a lilttle search on when to use  "sender uses virtual receiver" option.i came to an understanding that it is mainly used to handle multiple input file formats in a single configuration scenario.
    one more qns:
    What are marketplace adapters,is this error comes when we use adapters which are not inbuilt or bought from external vender.
    Regards,
    Anika
    Edited by: Anika Gulati on Jun 10, 2009 1:23 PM

    Here are few ways for it...
    SAP Process Integration: When to Use u201CSender Uses Virtual Receiveru201D in a Sender Agreement
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40cb67f7-6464-2b10-bcb9-8edb9a3569f9
    SAP Network Blog: Virtual Receiver - Why do you 'really' need it?
    /people/shabarish.vijayakumar/blog/2008/09/16/virtual-receiver--why-do-you-really-need-it
    -SM

  • How to automate DB health check report using OEM 11g

    Hi,
    I have been asked to share the DB health check report using OEM 11g. Could you please let me know how to achieve this and the report should go to his email.
    Thanks in advance,
    Bala

    check,
    manually you can schedule it through dbms_hm
    http://www.oracle.com/technetwork/articles/sql/11g-resiliency-091703.html

  • Interactive questions using IP/TV

    I am interested in how users can post questions using IP/TV while the presentation is ongoing. What is the process behind this as I don't really see how it works, any kind of insight would be useful.
    Many thanks Alex

    When you set up the program, you can (or not) enable interactive "from the field" questions.
    The client provide a button that can be pressed to flag the presenter that a field question is pending.
    The presenter can then address the questions as possible.
    Depending on the scope and location of the audience, you may also consider bringing up a conference bridge for voice-based questions.
    Good Luck
    Scott

  • Check printing using dot matrix printing?

    HI all,
    I have developed check printing using smartform for laser printer now the my client requirment has changed they are now using a dot matrix printer for check printing, so what parameter should i consider for developing a check printing for dot matrix printing

    the same smartform and driver program will work for all kind of printer.

  • How can I save a jepg file in lower case letters? I check the use lower case box in preferences but it's not happening. PSCC

    how can I save a jepg file in lower case letters? I check the use lower case box in preferences but it's not happening. PSCC

    Let's try a preferences reset: (Windows)
    Press and hold Control - Shift - Alt immediately upon cold-starting Photoshop.  If you get the keys down quickly enough - and you have to be VERY quick - it will prompt you to confirm deletion of your established preferences, which will lead to them all being set to defaults.

  • DTP-extraction-tab:Check-box 'use aggregates' what does it mean?

    Hello BW experts
    Can someone explain in simple words, what das it mean the check box  'use aggregates'  in the data transfer process (Tab extraction).
    The F1-help gives the following explanation  -however I don't understand the info-:
    'Should aggregates be used? This also means that an additional selection condition is automatically inserted that restricts to rolled up data requests.'
    Best regards and thank you to help to understand
    Christian
    PS: We are loading data from cube to cube
    Edited by: Christian Baumann on Jan 9, 2009 9:24 AM
    Edited by: Christian Baumann on Jan 9, 2009 9:26 AM
    Edited by: Christian Baumann on Jan 9, 2009 9:27 AM

    Hi Christian,
    I have never tried it myself , but I guess, it would mean if aggregates are built on the cube from which the DTP was extracting data you could choose to extract data from the aggregates instead.
    The aggregates are the same as a cube, but with fewer characteristics and would hold data at a summarized level.
    If this summarized level is sufficient for load to downstream infoproviders you could choose to extract from the aggregates.
    This would mean lesser data is read during extraction and extraction would be faster.
    SAP excerpt
    With InfoCubes as the source: Use extraction from aggregates
    With InfoCube extraction, the data is read in the standard setting from the fact table (F table) and the table of compressed data (E table). To improve performance here, you can use aggregates for the extraction.
    Select data transfer process Use Aggregates on the Extraction tab in the DTP maintenance transaction. The system then compares the outgoing quantity from the transformation with the aggregates. If all InfoObjects from the outgoing quantity are used in aggregates, the data is read from the aggregates during extraction instead of from the InfoCube tables.
    Regards,
    Sunmit.

  • C6380 Printer's always running out of ink. Is there a way to check printer use history?

    c6380 printer always seem to run out of ink. Is there any way to check printer use history. No one owns up to using it much, but we also seem to run through paper. Maybe the pets are secretly using it?

    Hi - This may not be exactly what you're looking for but the Extended Self-Test page does provide a page count.  It doesn't give you a history of when pages were printed, but it will at least tell you have many pages have been printed overall.
    Hope that helps.
    Kevin
    Say Thanks by clicking the Kudos thumbs up. Please mark the post that solves your problem as an Accepted Solution so other forum users can utilize the solution.
    I am an HP employee.

  • How to disable CD-DRIVE checking, while using a Dolphin file manager

    Hello.
    I  would like ask for a help. I have one problem that's quite annoying. It is related to checking cd-drive when using a dolphin file menager. It always cheecks it when Dolphin is launched from K or launcher on taskbar for the first time, again it happens when i close it and open again.
    Is there a way to disable checking of cd-drive in Dolphin? This behaviour occurs on KDE with all linux system that i checked: Slackware, Arch, Kubuntu. Look at this:
    Disabling CD-DRIVE checking, while using a file manager
    I would like to disable it in order to speed up opening Dolphin, launching it.

    Udisks2 is what dolphin uses to handle external drives of all kinds (USB, optical, etc).  Udisks is an automounting tool that allows normal users to mount disks.  The permission handling before was handled with consolekit and has now been replaced by systemd-logind (which is much better anyway).  So what I am suggesting is that it might be that dolphin is using udisks2 as the tool that polls for the existence of a disc in your optical drive.
    Unfortunately, it is a bit more confusing than that because udisks2 is the replacement for the original udisks.  It is totally different and not compatible.  So I remember seeing a way to turn off optical drive polling, but I cannot remember if it was udisks or udisks2.  But it was done with a udev rule. 
    So I think if you tried to google for "udisks optical (or cd or dvd) polling" or something like that, you might be able to figure out how this is done.
    Edit: unfortunately, I do not use dolphin or udisks2.  But I do have the original udisks installed.
    Edit2: It seems that the method I remembered is for the original udisks.
    Last edited by WonderWoofy (2013-07-25 17:51:56)

  • What is extractor checker and use of it...?

    Hello,
    Could you please help to know about extractor checker and use of it.
    Thanks in advance,
    G Raghu.

    Hi..........
    The extractor checker comes packaged in Service API (SAPI), which enables you to create generic DataSources via transaction RSO2. The extractor checker has been available since very early SAP releases (both SAP_APPL including the 3.X track and BW including the 2.X track). It can be considered release-independent. It does not require the source system to be connected to the target BW system. For more information about SAPI, go to SAP Service Marketplace. You search SAP notes using the keyword u201CSAPI.u201D
    By running the extractor checker in the debug mode, you can learn a lot about the underlying application. I have been in situations where I had to work with application-specific standard extractors in areas that Iu2019m only vaguely familiar with. Running the extractor checker in the debug mode has helped me identify the base tables without a lot of effort.
    I have seen generic extractors delivering no data because of faulty logic/coding. The reaction on the BW side is usually one of bewilderment and disbelief. You can avoid this by running the extractor check before executing your InfoPackages from BW. Iu2019ll show you how to use this tool in a more effective way and explain why you might want to use it more frequently.
    For extraction of data we create datasource in the source system.............after that we replicate it in the BW side...............
    Now our datasource can extract data from any:
    Table or view
    Query
    Function mudule.................................
    Now to check whether thae datasource is working fine or not.........We have to go to RSA3 in the source system...........There we will give the Datasource name.................then we will execute.........then it will displsy the data it contains...............we can also check for a specific value......
    Hope this helps you..........
    Regards,
    Debjani........

  • How to check JVM used memory in code?

    Hello,
    In my code I want to check JVM used memory and dump to a log file. Is any way to do that?
    Thx a lot!
    SG

    Ok, you've been a forum member for how long? Anyway, look at the javadocs:
    http://java.sun.com/j2se/1.4.2/docs/api/
    See the Runtime class.

  • Is this now where to ask DVD Studio Pro questions?  If not, please let me know where.  Here's my question:  Using DVD Studio Pro 3, when trying to burn a disc which is 4.5GB, I get error message "Not eough disk space in target folder".  What to do?

    Is this now where to ask DVD Studio Pro questions?  If not, please let me know where.  Here's my question:  Using DVD Studio Pro 3, when trying to burn a disc which is 4.5GB, I get error message "Not eough disk space in target folder".  What to do?

    Thanks.  Unfortunately, I need to make a master DVD that can then be duplicated in bulk as a single layer disc.  This surprises me because I tried burning a different DVD project that has worked in the past which is also 4.5 GB and now I could not burn that either.  I also reencoded some material to get the new project down to 4.4 GB but it still would not burn.  Any ideas are appreciated.

  • Other ways to check for used port

    Hi,
    I have this code to check for used port :
    try {
    ServerSocket s = ServerSocketFactory.getDefault().createServerSocket(port);
    s.close();
    } catch (Throwable e1) {
    InstallLogger.instance().info("Unable to open port " + port + ".\n" + e1.getMessage());
    return false;
    The code works fine. But in Windows 2003, it behaves differently. It does not detect that a "tomcat shutdown port" is already in use. Any other used port throws an exception, which is what is expected. Any idea will be appreciated. Thanks!

    below code loops till it gets a open port
         private int port = 2562;
         public void checkPort() {
              try {
                   ServerSocket sock = new ServerSocket(port);
                   sock.close();
                   System.out.println(port + " port is open");
              }catch(BindException b) {
                   System.out.println(port + " port is not available");
                   port++;
                   checkPort();//will check till it gets a open port.
              catch (IOException e) {
                   //do other validations
         }

Maybe you are looking for

  • How do I setup Active Directory and Group Policy on Windows Server 2012?

    I work for a school district that uses a Windows 2012 server with about 400 Windows 7 PCs and 150 Mac PCs. We are set up with Roaming Profiles on the PCs and would like to be able to setup Active Directory, Group Policy, and Roaming Profiles on our m

  • I want to create an ALV  with two row fields name

    Hi I want to create an ALV  with two row fields name. please suggest how to do it or send some sample code thanks

  • MBP Display Parameters for Running Soloris in Parallels

    I just got Solaris installed through Parallels. Thing is, Soloris doesn't recognize any of the video parameters through Parallels. I have to go in there and put them in manually. Currently, the res is stuck at 1600x1200 which is too big for my displa

  • End of tns data chanel in jdbc 10.1.0.4.0

    hi, i have two db's, 10.2.0.1 db and 8.1.7 db. in both db's there are the schem1 and schem2 schems. i created a table in db10g.schem1 (table1), and a public synonym for all the other schems in the db. in addition, in the 8.1.7 db there is a public sy

  • BSAD - Payment terms

    Hi friends, Im currently working on Receipt register report based on Sales employee & Brokers on their billed orders.The problem here I'm facing is there are two types of payment that one is Partial payment and Residual payment.So Im struggling to ge