Select Page

CS 1334 The University of Texas at Dallas Car Race with Arrays Java Code Project

Question Description

I’m working on a javascript exercise and need support to help me learn.

1. Write a function to draw a car, with the following input parameters:

  • x for horizontal position ?
  • y for vertical position ?
  • c for the car’s primary color ?

2. Create a variable to store the number of cars to draw. This will be your array size. ?initialize the variable, so that you’ll create at least 10 cars;

3. Since you will need multiple cars, create 3 arrays to store information about each car.
example: var xCars = [ ] ; //declare an array to store x-Position of each car

  • xCars for the horizontal position of the cars ?
  • yCars for the horizontal position of the cars ?
  • cCars for the color of the cars ?

4. Initialize each element (use a loop for each array):

  • xCars[ i ] each should initialized to 0 ?
  • yCars[ i ] each should be initialized to a random number between 0 and 399 ?
  • cCars[ i ] each should be a random color

5. Write code in the processing draw function with the following logic:

Use one for-loop to enclose logic that is repeated for each of the cars ?

  • draw each car
  • Increment the car’s x position with a random number between 1 and 5 ?
  • Check to see if any car has passed the “finish line” (i.e. x=399) ?
    if so, write the name of the winner (i.e. car 1, car 2, etc) and stop draw the draw loop from executing: use noLoop( );

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now