Ajout partie 2 (buggé)
This commit is contained in:
parent
8a8af36570
commit
e2c541d9fd
4 changed files with 15 additions and 16 deletions
|
@ -39,8 +39,9 @@ int main()
|
|||
[rd release];
|
||||
}
|
||||
*/
|
||||
NSLog(@"le résultat est : %d", [troupeau courseUne:1000]);
|
||||
NSLog(@"le résultat est : %d", [troupeau courseDeux:1000]);
|
||||
int time = 2503;
|
||||
NSLog(@"le résultat est : %d", [troupeau courseUne:time]);
|
||||
NSLog(@"le résultat est : %d", [troupeau courseDeux:time]);
|
||||
|
||||
//finir le main par ça
|
||||
[contentFile release];
|
||||
|
|
|
@ -38,17 +38,18 @@
|
|||
- (int) updateDistance
|
||||
{
|
||||
if (cooldown > 0)
|
||||
{
|
||||
cooldown--;
|
||||
if (cooldown == 0)
|
||||
hypervitesse = boostTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
distance += speed;
|
||||
distance = distance + speed;
|
||||
hypervitesse--;
|
||||
if (hypervitesse == 0)
|
||||
cooldown = pause;
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@interface Troupeau : NSObject
|
||||
{
|
||||
NSMutableArray *troupeau;
|
||||
NSSortDescriptor *recetteTri;
|
||||
NSArray *recetteTriDistance;
|
||||
}
|
||||
|
||||
- (id) init;
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
recetteTri = [[NSSortDescriptor alloc] initWithKey:@"distance"
|
||||
ascending:YES];
|
||||
NSSortDescriptor *recetteTri = [[NSSortDescriptor alloc] initWithKey:@"distance"
|
||||
ascending:NO];
|
||||
recetteTriDistance = [NSArray arrayWithObject:recetteTri];
|
||||
troupeau = [[NSMutableArray alloc] init];
|
||||
}
|
||||
return self;
|
||||
|
@ -41,16 +42,12 @@
|
|||
{
|
||||
int t = [rd updateDistance];
|
||||
}
|
||||
NSArray *tmp = [NSArray arrayWithObject:recetteTri];
|
||||
NSArray *sortedRank = [troupeau sortedArrayUsingDescriptors:tmp];
|
||||
[[sortedRank firstObject] updatePoints];
|
||||
NSLog(@"%d", [[sortedRank firstObject] points]);
|
||||
NSLog(@"Rennes : %@ pour une distance de %d", [[troupeau firstObject] name], [[troupeau firstObject] distance]);
|
||||
// copier dans le troupeau le tableau trié
|
||||
[troupeau sortUsingDescriptors:recetteTriDistance];
|
||||
[[troupeau firstObject] updatePoints];
|
||||
time--;
|
||||
}
|
||||
NSSortDescriptor *tt = [[NSSortDescriptor alloc] initWithKey:@"points"
|
||||
ascending:YES];
|
||||
ascending:NO];
|
||||
NSArray *tmpp = [NSArray arrayWithObject:tt];
|
||||
NSArray *sortedPonits = [troupeau sortedArrayUsingDescriptors:tmpp];
|
||||
NSLog(@"%d", [[sortedPonits firstObject] points]);
|
||||
|
@ -64,7 +61,7 @@
|
|||
for (Raindeer *rd in troupeau)
|
||||
[rd dealloc];
|
||||
[troupeau release];
|
||||
[recetteTri release];
|
||||
//[recetteTri release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue