Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Alice Programming Assignment: Loops

Program Requirements

This Alice program will contain 2 scenes. In the first scene, two cars will pop wheelies multiple times. In the second scene, the two cars will race towards an object in the middle of the scene and see who wins.

Create an Alice program that minimally does the following:

Setting the Scene

• Start with a blank slate.

• Add two sports car objects (from the Automobile class, within the Transport class) to the scene, and adjust the car heights to both be size

• Turn the cars so they are facing each other.

• Use the middle camera adjustment arrow to zoom out a bit so you can see more of the scene (click on arrow at least 5 times).

• Move the cars to either side of the screen, at the same Z-axis position -- one on the far left side of the screen facing right, and one on the far right side of the screen facing left (make sure both cars are fully visible when you run your code).

• Place an object from the Prop class in the middle of the scene between the two cars, also at the same Z-axis position. Make the Prop object fairly small.

Creating Methods

• Add two scene methods, doScene1 and doScene2.
• Add a shot method called race, which will run from within the doScene2.
• Within the Automobile class, add a procedure method called popWheelie, which causes an automobile to pop a wheelie.

Coding the Actions

Add code to the popWheelie method to make a sports car:

• Simultaneously:

o Spin (turn) its back wheels several rotations.
o Raise the front end of the car (turn) a small amount off the ground.

• Return the car to the ground.

Add code to the doScene1 method to:

• Create a variable and store the half of the height of the Prop object in the variable.

• In a count loop, make the Prop object perform the following tasks three times in a row:

o Spin around 360 degrees.
o Move up by half its height
o Move down by half its height

• Prompt the user to enter how many times the cars should pop wheelies.

• In a while loop, validate the number of times entered:

o If the number of times entered is less than 1

- Have one of the cars say that it must pop at least one wheelie
- Read another value from the user Loop until a valid value is entered (1 or more).

• In a count loop:

o Simultaneously invoke the popWheelie method for both cars, to make both cars pop the specified number of wheelies, at the same time.

Add code to the doScene2 method to:

• Create a variable and store the distance from the left car to the Prop object in the variable.

• Create a second variable and store the distance from the right car to the Prop object in the variable.

• Have the each car say how far it is from the Prop object.

• Create a variable moveLeftCarDistance to hold the distance the left car will move each time, and set it to be one tenth of the distance from the left car to the Prop object.

• Create a variable to hold a move factor for the right car.

• Have the right car ask the user what factor to use to move it, and explain that it must be a double between 5 and 15. Store the user input into the move factor variable.

• Within a while loop

o Test to see whether the move factor the user entered is invalid (i.e. between 5 and 15)
o If the value entered is invalid

- Have the right car say why the factor entered is incorrect
- Prompt for and read another value into the move factor. Loop until a valid value is entered.

• Create a variable moveRightCarDistance to hold the distance the right car will move each time, and set it to the value of the distance from the right car to the Prop object divided by the move factor.

• Invoke the race method to make the cars race to the Prop object.

o Pass the two move distance variables as arguments to the race method.

Add code to the race method to:

• Take 2 parameters

o The first parameter defines the amount that the left car will move each time.
o The second parameter defines the amount that the right car will move each time.

• Create a Boolean variable that will indicate whether the race should continue, and set it to an initial value of true.
• In a while loop that runs as long as the boolean is true:

o Move the left car forward by its parameter amount
o Move the right car forward by its parameter amount.
o Check to see if the left car reached (collided with) the Prop object (Hint: use built-in isCollidingWith method). If so:

- Have that car say that it won the race.
- Reset the Boolean flag so that the loop will exit Otherwise, do nothing and continue with the next check.

o Check to see if the right car reached (collided with) the Prop object. If so:

• Check to see if the left car also reached the prop object (i.e. the boolean was reset already). If so:

o Have that car say that the other car did not win, but they tied instead. Otherwise:
o Have that car say it won the race.
o Reset the Boolean flag so that the loop will exit Otherwise (right car has not reached Prop), do nothing and loop.

This loop should run until one (or both) car(s) reaches (collides with) the Prop object.

Note that you can test all possibilities for this loop by adjusting the move factor entered in Scene 2 to make each possibility occur.

Make sure the duration of each movement in your animation is long enough to view comfortably. Run, test, and debug your Alice program, until it works correctly.

Optionally you may add one or more methods that will use a loop to cause the objects to perform some other behavior more than once.

NOTE: The new behavior cannot be a behavior implemented by any of the course materials.

The method(s) should be invoked from an additional extraCreditScene method.

Warning: Do not attempt to implement the extra credit unless you have first successfully implemented the normal part of the assignment. You will not receive any extra credit if the normal part of the assignment is not functioning properly. Be sure to save a copy of the normal part of the assignment, in case your efforts on the extra credit are unsuccessful.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92053672
  • Price:- $150

Priced at Now at $150, Verified Solution

Have any Question?


Related Questions in Programming Language

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As