Results 1 to 4 of 4
  1. #1
    zakur0 is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Transfering arralist info <type problem>

    Ok this is an university assignment and i cant go on and change the code at will :/
    its about a program reading a txt with football matches info
    there are 5classes (with main)
    fileparser(scans the txt) and creates an ArraList<match>(Team homeTeam,Team visitorTeam,int date,int hTscore, int vTscore)

    match(contains the constructor that just gives data to Team homeTeam,Team visitor Team etc) + it contains a printMatch method

    team(constructor takes a String and gives it points = 0; +getter/setter for points and getter for name)

    and now the place where my mind is f*****
    Java Code:
    import java.util.ArrayList;
    
    public class MatchAnalyser {
        private ArrayList<Team> teamsList;
    	public MatchAnalyser(ArrayList<Match> matchesList){
    		teamsList = new ArrayList<Team>();
    		for(int i = 0 ; i < matchesList.size(); i++){
    			teamsList.add(   /*missingCode*/  );
    		}
    	}
    i cant move matchesList.homeTeam since its not a field...and i cant really getanything to work :/
    Last edited by Norm; 11-29-2011 at 04:13 PM. Reason: added code tags removed ...

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Transfering arralist info <type problem>

    i cant move matchesList.homeTeam
    Please explain what you are trying to do and what your problem is.

  3. #3
    zakur0 is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: Transfering arralist info <type problem>

    What i am tryig to do is move the Team homeTeam and Team visitorTeam objects that are inside the ArrayList<Match>.
    however the arrayList in whichi try to MOVE the ojects is of a Team type...and because itsa projext and i can only fill in stuff where i am supposed to do cant change what the constructor of MatchAnalyser gets

    generaly the problem is
    ArrayList<Match> matchesList (Team homeTeam,Team visitorTeam,integere,integer,integer)

    has to move the first two TEAM objects into
    ArrayList<Team> teamList


    this whole project is about a program that reads a txt using util.scanner sets points depending on team performance and teamList with the new set of points for each team is going to be printed onto a .txt file

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Transfering arralist info <type problem>

    tryig to do is move the Team homeTeam and Team visitorTeam objects that are inside the ArrayList<Match>.
    Those two objects sound like they would be members of the Match object.
    The Match object needs to have getter methods that return references to the homeTeam and to the visitorTeam objects (2 methods, one for each).
    Then you can add those Team objects to the teamList arraylist.

Similar Threads

  1. Replies: 6
    Last Post: 04-10-2011, 04:40 AM
  2. A problem for put the file info to arrary
    By l0afer in forum New To Java
    Replies: 11
    Last Post: 03-28-2011, 06:48 AM
  3. passing type info to a method during run time
    By alinaqvi90 in forum Advanced Java
    Replies: 2
    Last Post: 10-20-2010, 02:03 PM
  4. passing info between server/client problem
    By DarkBlaze in forum New To Java
    Replies: 13
    Last Post: 07-24-2008, 03:14 AM
  5. How to fetch an arralist element (i need the code)
    By raj reddy in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 04-21-2008, 03:28 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
  •