Results 1 to 5 of 5
- 06-06-2009, 06:35 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 28
- Rep Power
- 0
help to solve tis problem in method
Hello,
I have a problem with this method:
This method should add RaceDriver to Team, the method word correctly, but there is one mistake.PHP Code:public boolean addRaceDrivertoTeam(String driverLicenseNumber,String nationality,String constructorName, String fullName, Date dateOfBirth , int worldChampionships, int totalScore, int highestRaceFinish){ RaceDriver driver = new RaceDriver(driverLicenseNumber,fullName,nationality, dateOfBirth,worldChampionships,totalScore, highestRaceFinish); Constructors con; con = Constructors.valueOf(constructorName); RaceTeam team= new RaceTeam(con); if (driver.getRaceDriverKey()!=null) if (raceTeam.containsKey(con)&&(driver != null) && !team.isDriverExists(driver)){ team.addRaceDriver(driver); return true; } return false; }
every Team can include just at 3 drivers .
I didn't know how I can limit it/
i try limit it from the addRaceDriver() method that in the RaceTeam class but i didn't succed.
this is the addRaceDriver() method:
anyone can help me how to do this ?PHP Code:public boolean addRaceDriver(RaceDriver driver){ if (raceDriver != null && !raceDriver.containsKey(driver.getRaceDriverKey())){ raceDriver.put(driver.getRaceDriverKey(), driver); return true; } return false; }
- 06-06-2009, 07:00 PM #2
you can check the size of the collection b4 adding driver.
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 06-06-2009, 09:53 PM #3
Member
- Join Date
- Apr 2009
- Posts
- 28
- Rep Power
- 0
Hello'
I do this and added a new check:
but it's didn't help !!!PHP Code:if (driver.getRaceDriverKey()!=null) if (raceTeam.containsKey(con)&&(driver != null) && !team.isDriverExists(driver) && (raceTeam.size()<3)){ team.addRaceDriver(driver); return true; }
- 06-07-2009, 11:47 AM #4
Member
- Join Date
- Apr 2009
- Posts
- 28
- Rep Power
- 0
I try to change in the method, maybe one of the two methods is wrong because id the addRaceDrivertoTeam() method return:
return team.addRaceDriver(driver);
and the method returns false :(!!!
maybe that meaning that the wrong from addRaceDriver() method !!
this is the methods:
this method in sys class:
and this in RaceTeam class:PHP Code:public boolean addRaceDrivertoTeam(String driverLicenseNumber,String nationality,String constructorName, String fullName, Date dateOfBirth , int worldChampionships, int totalScore, int highestRaceFinish){ RaceDriver driver = new RaceDriver(driverLicenseNumber,fullName,nationality,dateOfBirth,worldChampionships,totalScore, highestRaceFinish); Constructors con; con = Constructors.valueOf(constructorName); RaceTeam team= new RaceTeam(con); if (driver.getRaceDriverKey()!=null) if (raceTeam.containsKey(con)&&(driver != null) && !team.isDriverExists(driver)){ return team.addRaceDriver(driver); } return false; }
this is the prototype for th sys class:PHP Code:public boolean addRaceDriver(RaceDriver driver){ if (raceDriver != null && raceDriver.containsKey(driver.getRaceDriverKey())){ raceDriver.put(driver.getRaceDriverKey(), driver); return true; } return false; }
and this is for the RaceTeam class:PHP Code:protected Map <String, RaceCar> raceCar =new HashMap<String, RaceCar>(); protected Map <String, Race> race =new HashMap<String, Race>(); protected Map <Constructors,RaceTeam>raceTeam=new HashMap<Constructors,RaceTeam>(); protected Map <String, RaceTrack> raceTrack =new HashMap<String, RaceTrack>();
where is the problem in this methods :( ???!!PHP Code:protected Constructors name; protected int totalScore; protected URL website; protected double budget; protected String lastRace; protected Race race; protected HashMap <String,RaceDriver> raceDriver;
Last edited by alrebatsd; 06-07-2009 at 11:50 AM.
- 06-07-2009, 03:35 PM #5
I haven't a clue, maybe writing a small test program will help.
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
Similar Threads
-
Factory problem: How to Solve it
By rahul_capricorn in forum Threads and SynchronizationReplies: 2Last Post: 02-11-2009, 04:47 PM -
Help me to solve problem
By mansoorhacker in forum Forum GuidesReplies: 8Last Post: 01-24-2009, 06:29 PM -
Factory problem: How to Solve it
By rahul_capricorn in forum Advanced JavaReplies: 1Last Post: 01-14-2009, 01:10 PM -
Solve my Problem
By kyo in forum New To JavaReplies: 1Last Post: 12-16-2008, 02:22 PM -
Help me to solve problem
By mansoorhacker in forum New To JavaReplies: 3Last Post: 11-13-2008, 08:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks