Z
zcraven
Joona I Palaste said:zcraven <[email protected]> scribbled the following
Ah yes. If you have defined your method parameters like that, then by
the time your method is even called, you are already guaranteeing to
the compiler that g1 is of type Goalkeeper and p2 through p11 are of
type OutfieldPlayer, so the whole if statement in the method becomes
needless.
I had thought that all parameters, both g1 and p2 through p11, were of
type Player. If they are then the code I showed (for this method) should
compile.
Could you also show the code for the method that is calling this method?
public static Club createCLUBManUtd()
{
Club c1 = new Club("Man Utd");
Goalkeeper g1 = new Goalkeeper(c1, "Peter", "Tom", "Schmeichal",
195, 1973, 8, 3);
Goalkeeper g2 = new Goalkeeper(c1, "Roy", "Phil", "Carroll", 189,
1980, 9, 7);
OutfieldPlayer p1 = new OutfieldPlayer(c1, "Micheal", "Abbey",
"Silvestre", 179, 1974, 12, 2, "defender");
OutfieldPlayer p2 = new OutfieldPlayer(c1, "Rio", "John",
"Ferdinand", 185, 1967, 04, 25, "defender");
OutfieldPlayer p3 = new OutfieldPlayer(c1, "Phil", "Bob", "Neville",
169, 1975, 11, 2, "defender");
OutfieldPlayer p4 = new OutfieldPlayer(c1, "Gary", "Steve",
"Neville", 166, 1974, 2, 2, "defender");
OutfieldPlayer p5 = new OutfieldPlayer(c1, "Claude", "Scot",
"Heinz", 159, 1969, 2, 4, "defender");
OutfieldPlayer p6 = new OutfieldPlayer(c1, "Christaino", "Alex",
"Ronaldo", 178, 1982, 10, 12, "midfielder");
OutfieldPlayer p7 = new OutfieldPlayer(c1, "Ryan", "Jamie", "Giggs",
195, 1973, 1, 2, "midfielder");
OutfieldPlayer p8 = new OutfieldPlayer(c1, "Paul", "John",
"Scholes", 179, 1973, 4, 7, "midfielder");
OutfieldPlayer p9 = new OutfieldPlayer(c1, "Wayne", "OAP", "Rooney",
175, 1975, 3, 7, "striker");
OutfieldPlayer p10 = new OutfieldPlayer(c1, "Loius", "Sean", "Saha",
177, 1976, 9, 12, "striker");
OutfieldPlayer p11 = new OutfieldPlayer(c1, "Ruud", "Stan", "Van
Nistelrooy", 180, 1977, 12, 9, "striker");
OutfieldPlayer p12 = new OutfieldPlayer(c1, "Alan", "Steve",
"Smith", 179, 1980, 10, 10, "striker");
c1.addPlayer(g1);
c1.addPlayer(g2);
c1.addPlayer(p1);
c1.addPlayer(p2);
c1.addPlayer(p3);
c1.addPlayer(p4);
c1.addPlayer(p5);
c1.addPlayer(p6);
c1.addPlayer(p7);
c1.addPlayer(p8);
c1.addPlayer(p9);
c1.addPlayer(p10);
c1.addPlayer(p11);
c1.addPlayer(p12);
c1.setFirst11(g1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
c1.updateClubStats(0,2);
c1.updateClubStats(0,4); // creates equal points and goal
difference to arsenal, but a higher goals scored.
c1.updateClubStats(0,0);
return c1;
}
This is a 'test data' method that creates a club. this is the only method
so far that calls the club.setFirst11 method.
Probably I will change all the values in the setFirst11 method header to
'Player', and then check them for goalkeeper/outfield as you suggested.