Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Game The game begins with the player in possession of 0 total daisies. The player is placed in a random spot [ row, col

The Game The game begins with the player in possession of 0 total daisies. The player is placed in a random spot [ row, col ] in a grid with 10 rows and 10 columns, each spot has a random number of daisies from 0-999. To make displaying the grid easier, think of row 0 column 0 [ 0, 0 ] being in the upper left corner and row 9 column 9 [ 9, 9 ] in the lower right corner: The player has seven choices: Gather daisies, Jump to another spot, go North, go South, go East, go West, or Quit.

Gathering Daises - when the player chooses to gather daisies they can't get them all, only 80% can be gathered at once - so 80% of the daisies are removed from the spot and added to their total daisies. After gathering daisies the player remains in the spot.

Jump - when the player chooses to Jump, they are placed in a random spot, any one of the spots in the 10x10 grid.

North When the player selects north, they move up (row is one less) make sure the player doesnt fall off the board!

South When the player selects south, they move down (row is one more) make sure the player doesnt fall off the board!

East When the player selects east, they move to the right (column is one more) make sure the player doesnt fall off the board!

West When the player selects west, they move to the left (column is one less) make sure the player doesnt fall off the board!

Map displays to the user the grid

Quit - when the player quits, they are told of the total number of daisies they gathered, the total number of jumps they took, and the total number of gatherings they made.

Technical Items for this Lab

Since this is a lab on Arrays, there are some specifics that need to be addressed like needing an array, so I will give some constraints to ruin your day...

To simulate the spots with daisies, use a two dimensional array (10x10) of integers.

Populate each element in the array with a random number from 0..999.

For interacting with the user, allow the user to enter J for jump, G for gather, N for North, S for South, E for East, W for West, and Q to quit.

The spots displayed are in the format [row, col]

Sample Run

You are in spot [1, 9]

There are 203 daisies located here

You currently have a total of 0 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): m

Map of Grid:

568 218 321 863 141 342 304 624 49 126

250 127 98 57 911 713 265 885 426 203

184 912 829 703 124 667 667 735 943 822

282 893 749 734 916 77 336 515 144 466

362 495 90 549 502 577 259 173 556 335

310 544 471 50 585 783 293 387 700 743

578 12 809 588 185 193 504 688 505 972

701 273 319 736 160 633 326 878 281 255

352 563 902 707 735 179 219 462 84 878

965 79 795 248 387 906 377 479 401 804

You are in spot [1, 9]

There are 203 daisies located here

You currently have a total of 0 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): s

You are in spot [2, 9]

There are 822 daisies located here

You currently have a total of 0 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 657 daisies from this spot!

You are in spot [2, 9]

There are 165 daisies located here

You currently have a total of 657 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): e

You are in spot [2, 9]

There are 165 daisies located here

You currently have a total of 657 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): e

You are in spot [2, 9]

There are 165 daisies located here

You currently have a total of 657 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): w

You are in spot [2, 8]

There are 943 daisies located here

You currently have a total of 657 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 754 daisies from this spot!

You are in spot [2, 8]

There are 189 daisies located here

You currently have a total of 1,411 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): m

Map of Grid:

568 218 321 863 141 342 304 624 49 126

250 127 98 57 911 713 265 885 426 203

184 912 829 703 124 667 667 735 189 165

282 893 749 734 916 77 336 515 144 466

362 495 90 549 502 577 259 173 556 335

310 544 471 50 585 783 293 387 700 743

578 12 809 588 185 193 504 688 505 972

701 273 319 736 160 633 326 878 281 255

352 563 902 707 735 179 219 462 84 878

965 79 795 248 387 906 377 479 401 804

You are in spot [2, 8]

There are 189 daisies located here

You currently have a total of 1,411 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): j

You are in spot [2, 3]

There are 703 daisies located here

You currently have a total of 1,411 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 562 daisies from this spot!

You are in spot [2, 3]

There are 141 daisies located here

You currently have a total of 1,973 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): m

Map of Grid:

568 218 321 863 141 342 304 624 49 126

250 127 98 57 911 713 265 885 426 203

184 912 829 141 124 667 667 735 189 165

282 893 749 734 916 77 336 515 144 466

362 495 90 549 502 577 259 173 556 335

310 544 471 50 585 783 293 387 700 743

578 12 809 588 185 193 504 688 505 972

701 273 319 736 160 633 326 878 281 255

352 563 902 707 735 179 219 462 84 878

965 79 795 248 387 906 377 479 401 804

You are in spot [2, 3]

There are 141 daisies located here

You currently have a total of 1,973 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 112 daisies from this spot!

You are in spot [2, 3]

There are 29 daisies located here

You currently have a total of 2,085 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 23 daisies from this spot!

You are in spot [2, 3]

There are 6 daisies located here

You currently have a total of 2,108 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 4 daisies from this spot!

You are in spot [2, 3]

There are 2 daisies located here

You currently have a total of 2,112 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): g

You just gathered 1 daisies from this spot!

You are in spot [2, 3]

There are 1 daisies located here

You currently have a total of 2,113 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): m

Map of Grid:

568 218 321 863 141 342 304 624 49 126

250 127 98 57 911 713 265 885 426 203

184 912 829 1 124 667 667 735 189 165

282 893 749 734 916 77 336 515 144 466

362 495 90 549 502 577 259 173 556 335

310 544 471 50 585 783 293 387 700 743

578 12 809 588 185 193 504 688 505 972

701 273 319 736 160 633 326 878 281 255

352 563 902 707 735 179 219 462 84 878

965 79 795 248 387 906 377 479 401 804

You are in spot [2, 3]

There are 1 daisies located here

You currently have a total of 2,113 daisies

What would you like to do? (G, J, N, S, E, W, M, Q): q

You gathered a total of 2,113 daisies!

You did it in 1 jumps and 7 number of gatherings

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago