Results 1 to 3 of 3
  1. #1
    souaden12 is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default Terminal problem

    I've been having a problem with the terminal displaying the information I want
    In the following method, the user enters an id and if the id exists in the players' IDs, then the method should display the information about the player associated with this id in the terminal

    What I have done is using the scanner class to allow the user to enter the id he wants to search for
    Also in the main method i've put a while loop around the searchID method call to keep calling it as long as some string is equal to "yes" (just for the sake of testing)

    The thing is when the terminal shows the users enter an id, lets say 1, and then another one, lets say 3 and so on
    So every time the user enters an id the terminal shows the information about the player
    However if the user keeps searching, the terminal does show the player associated with an id
    but it crops some of the information about the players that the user searched before

    this is the method
    Java Code:
    public String searchPlayer()
            int idSearch;
            idSearch = find.nextInt();
            for (Player player : players)
                if (idSearch == player.getPlayerID())
                    return player.toString();
            return "1";
    this is the main method
    Java Code:
    Club c1 = new Club("NCL");
            Player wicketkeeper = new WicketKeeper("Ali", "Alamiri", 20, 170, 65, 4, 6, 3, "Wicketkeeper", 5, 11);
            Player wicketkeeper1 = new WicketKeeper("Ali", "Alamiri", 20, 17, 65, 4, 6, 5, "Wicketkeeper", 5, 10);
            Player bowler = new Bowler("Ali", "Alamiri", 20, 170, 65, 4, 6, 3, "Bowler", 6, 3, 103);
            Player bowler1 = new Bowler("Ali", "Alamiri", 20, 170, 65, 4, 6, 3, "Bowler", 6, 3, 104);
            Player bowler2 = new Bowler("Ali", "Alamiri", 20, 170, 65, 4, 6, 3, "Bowler", 6, 3, 105);
            Player bowler3 = new Bowler("Ali", "Alamiri", 20, 170, 65, 4, 6, 3, "Bowler", 6, 3, 106);
    String find = "yes";
    so now when the user runs the program, lets say he enters the following IDs

    The program will show the information of the player with id 1(which is wicketkeeper) fine, and also the ones with 2 and 3 and 4
    but when it shows the information for the fourth id, it crops some of the information for the 1 id
    so the information shown for the first id is this:

    First name: Ali
    Last name: Alamiri
    Age: 20 years
    Height: 170cm
    Weight: 65kg
    Player position: Wicketkeeper
    Number of games played: 4
    Number of runs scored: 6
    Number of times dismissed: 3
    Number of catches: 5
    Number of stumpings: 11

    but when I reach 4, it crops the first two information about the player (first and last name)
    and if i keep going to id 5 and 7 and so on, it keeps cropping parts of the information about players
    so if i keep searching for 10 IDs, it might crop the first and last name as well as the age height and weight and so on

    what exactly is causing this?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Terminal problem

    when it shows the information for the fourth id, it crops some of the information
    Please post the output that shows what is happening.
    Add some comments to the out put that says what is wrong with it and what it should be.

  3. #3
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    London, UK
    Blog Entries
    Rep Power

    Default Re: Terminal problem

    You're talking about command-line terminal right? It's normal... it doesn't mean there is a problem with your program, it's just that the command line terminal has a limit to the number of lines it displays before the stuff at the top gets wiped over.

    Maybe you should use a JFrame instead to output your text?

Similar Threads

  1. Replies: 2
    Last Post: 10-16-2011, 04:42 AM
  2. Typing into terminal
    By keo in forum New To Java
    Replies: 1
    Last Post: 03-15-2011, 10:09 AM
  3. Mac Terminal
    By Java8 in forum Other IDEs
    Replies: 0
    Last Post: 01-16-2010, 07:19 PM
  4. Terminal
    By dj kourampies in forum New To Java
    Replies: 7
    Last Post: 01-07-2009, 04:57 PM
  5. Problem when displays in the terminal
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 02:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts