Results 1 to 4 of 4
- 11-29-2011, 02:56 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
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*****
i cant move matchesList.homeTeam since its not a field...and i cant really getanything to work :/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*/ ); } }Last edited by Norm; 11-29-2011 at 04:13 PM. Reason: added code tags removed ...
- 11-29-2011, 04:15 PM #2
Re: Transfering arralist info <type problem>
Please explain what you are trying to do and what your problem is.i cant move matchesList.homeTeam
- 11-29-2011, 04:45 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
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
- 11-29-2011, 04:52 PM #4
Re: Transfering arralist info <type problem>
Those two objects sound like they would be members of the Match object.tryig to do is move the Team homeTeam and Team visitorTeam objects that are inside the ArrayList<Match>.
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
-
Problem with subclass reading info from main class and vice versa
By JR2010 in forum New To JavaReplies: 6Last Post: 04-10-2011, 04:40 AM -
A problem for put the file info to arrary
By l0afer in forum New To JavaReplies: 11Last Post: 03-28-2011, 06:48 AM -
passing type info to a method during run time
By alinaqvi90 in forum Advanced JavaReplies: 2Last Post: 10-20-2010, 02:03 PM -
passing info between server/client problem
By DarkBlaze in forum New To JavaReplies: 13Last Post: 07-24-2008, 03:14 AM -
How to fetch an arralist element (i need the code)
By raj reddy in forum JavaServer Pages (JSP) and JSTLReplies: 7Last Post: 04-21-2008, 03:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks