Public RainDelay { RainDelay() { this.EnterRainZone(Car obj); } EnterRainZone() { obj.rainDelayStartTime = getTime(); do{ ; } while( keyPress !

= S ); // Until Race is again started. obj.rainDelayEndTime = getTime(); } }

public Class Car { // A variable which is incremented whenever a new object is created. static int no_of_Car_Objects_running; Time time, x, y, intervalTime, intervalStartTime, intervalEndTime, timeLapsed; Time rainDelayStartTime, rainDelayEndTime, intervalTimeStartPointer; String name; decimal startpos, totalDistanceCovered, totalDistanceRequired; int flag, speed; Car(string name, int pos, int speed, int totalDistance) { this.time = getTime(); this.name = name; this.startpos = pos; this.x = this.time; this.speed = speed; this.y = this.time; this.intervalStartTime intervalTimeStartPointer this.totalDistanceRequired } // static objects, blocks will be loaded first. static incrementStaticValues() { no_of_Car_Objects_running ++; } // Test No Of Objects Created. DisplayEveryThing(Systen.Object Obj1, String msg) { println( msg + " : " + no_of_Car_Objects_running); = = = this.time; this.time; totalDistance;

totalDistanceCovered) <= 0) { return (true). i++) { array_positions[i-1] = carobj + i. } else { this. this.ToString().TimeLapsed().EndGame(). } } TimeLapsed() { tempTimeVar = getTime() . } TotalDistanceCovered() { this. . for(int i = 1.DisplayPositions(). if((this.y.totalDistanceRequired . this. string[] array_names = new string[no_of_Car_Objects_running].this.ToString(). array_names[i-1] = carobj + i.IsTotalDistanceCovered()) { this.TotalDistanceCovered(). } else { return (false). this.} EnterRaceZone() { if(this.SetTimeCursors().totalDistanceCovere d.lapsed = tempTimeVar.this.totalDistanceCovered += this. } } DisplayPositions() { decimal[] array_positions = new decimal[no_of_Car_Objects_running]. i <= no_of_Car_Objects_running.speed * this.lapsedTime. } boolean IsTotalDistanceCovered() { this.name.

speed -= a.totalDistanceCovered() == false ) { if((this.Sort(array_positions.intervalTimeStartPointer. Println ( " Racers positions in ascending order: ") for(int i = 1.speed * this.a) <= 0 ) { this. } .1 ] ). } CalculateIntervalTime() { this. } CalculateIntervalDistance() { this. array_names).this. i <= no_of_Car_Objects_running.intervalTimeStartPointer = getTime().} // There is function in C# which sorts array1 in Sync with array2 Array.CalculateIntervalDistance(). i++) { println( array_names[ array_positions[i-1] ]).calculateIntervalTime().intervalTime = getTime() .y = getTime(). this. } } SetTimeCursors() { this.intervalDistance + = this. //println( array_names[ i .intervalTime. if( this. this. } DecreaseSpeed(int a) { // calculate interval distance covered before increasing speed. this.speed .speed = 1 } else { this.

CalculateIntervalDistance().EndGame().y . i <= no_of_Car_Objects_running. i++) { carobj + i. carobj + i.= tempTimeVar. this.y . } } KeyPressEvent() { if( keypress == UpArrow ) // increase speed { int a = get_no_Of_Seconds_Key_Pressed(). { RainDelay rX = new RainDelay(this).rainDelayEndTime .rainDelayStartTime). } else { this. } } RestoreTimePointers() { Time tempTimeVar = (this.this.RestoreTimePointers().DecreaseSpeed( (3^a) mod 20) ) } if( keypress == R ) // Indicates Rain-Delay. for(int i = 1. this.} } IncreaseSpeed(int a) { this.IncreaseSpeed( (3^a) mod 20) ) } if( keypress == UpArrow ) // decrease speed { int a = get_no_Of_Seconds_Key_Pressed(). if( this. this.totalDistanceCovered() == false ) { this.= tempTimeVar.ToString(). .ToString().speed += a.

} . Car[] carobjs = new Car[n]. total_track_distance. i++) { // pass name. i <= n. i++) { carObjs[i].no_of_Car_Objects_running. Read(n). i<=n.EnterRaceZone().} } } // End Car-Class. 50. position speed. 0. while(!raceEnd) { for(int i = 1. "No Of Cars partici pating are ").DisplayEveryThing(Car. public class Test { public static void Main() { boolean raceEnd = false. break. for( int i = 1. if(carObjs[i]. Car carobjs[i] = new Car("ABC". } // calling a static method to check no of objects created.flag == 1) { raceEnd = true.00. Println("Please enter number of cars participating in the race : "). Car. 2000).

} } } } .