• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validation - i think i need a 2d array ??

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
say if i have 6 or 7 fixtures for soccer matches. I want to check to see if a team isn't listed in any other fixture (ie, as a home or away team).

The fixtures are in an array with paramValues2[] as the home team and paramValues3[] as the away team. Ive only managed to check to see if the same team isn't in the home & away in a fixture.
this is the code for that...

for (int u=0; u < paramValues2.length; u++){
if (paramValues2[y].equals(paramValues3[u])){
response.sendRedirect("http://localhost:8080/FixtureError.jsp");
}

I can't figure out how to check to see if a team isn't listed in any other fixture. I thought i might be able to do it with something like a 2d array but i think i can only check to see if a home team isn't in all the away teams in all the fixtures or with an away team against all the home teams.
Any ideas?
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robert,

If it was me doing this (which it wouldn't be, because I don't like soccer ) I would perhaps write a Fixture class with homeTeam and awayTeam attributes. That way I could keep a list(array) of Fixtures, rather than a list of home teams and a list of away teams.

Assuming we keep the team names as String's, in my Fixture class I might then have a method to see if a particular team played a certain Fixture (whether as home or away team).

perhaps the method would look something like this, assuming there are homeTeam and awayTeam attributes in the Fixture class...



this would allow me to loop through my list (could be an array, or could be an ArrayList perhaps) of Fixture objects, calling the involvesTeam() method to see if a particular team was involved at that fixture.

Hope this makes sense! I think trying to put all this into an array will perhaps just make things more confusing.
[ March 30, 2005: Message edited by: Ben Wood ]
 
Robert Johnson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yea i see what you mean about having Fixture objects. I'll have to search through all the fixtures except for the fixture with the team its checking.
I'll work on it more but im still a bit lost.
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic