Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

servlet problem

  • 16-03-2006 12:49PM
    #1
    Posts: 24,286 ✭✭✭✭


    hi i am trying to create an error on my servlet where the players chosen from selection fields are matched to those in the database. if they match then get their value. calculate the value of all players and if the total is greater then a designated budget output an error, else send on to DB..


    i thought firstly you would do something like

    //get parameters (eg string gk and string d1)
    int budget = 10;
    int sum = -1;


    if(gk.equals(p.getName()) ) {

    int g = p.getValue();

    if d1.equals(p.getName()) {

    int 1d = p.getValue());
    sum = ( g + 1d);
    }}
    if (sum > budget){
    //output error msg

    am i right??


Comments

  • Registered Users, Registered Users 2 Posts: 27,517 ✭✭✭✭GreeBo


    you should name your variables something better
    though maybe gk is goalkeeper and d1 is first defender?
    You will need to add all the values so think of a way of doing the same addition multiple (11?) times just using different fields.
    Also, you know the names of the fields so maybe define them somewhere, might be useful.


Advertisement