Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Used the python program 1. Write the definition of the function displaySubMenu that displays the following menu; this function doesn't collect the user's input; only

Used the python program

1. Write the definition of the function displaySubMenu that displays the following menu; this function doesn't collect the user's input; only display the following menu.:

 [S]top  Press 'S' to stop. 

2. Write the definition of the function setNextGenList that creates a pattern of next generation (tempGen) based on the current generation (currentGen); modify the tempGen based on the currentGen by applying the rules of Game of Life.

Conway's Game of Life Rules:

- The neighbors of a given cell are the cells that touch it vertically, horizontally, or diagonally. - Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. - Any live cell with two or three live neighbours lives on to the next generation. - Any live cell with more than three live neighbours dies, as if by overpopulation. - Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

3. Create a loop to generate and next pattern automatically.

When executing your program, the following should happen: a. Print the menu using the displayMenu function. b. Initialize the tempGen using the setZeroList function. c. Set the U pattern in the tempGen using the setInitialPatternList function. d. Copy the tempGen to the currentGen using the copyList function. e. Print the currentGen using the displayList function. f. When the user presses P, loop the following steps: 1). Print the menu using the displaySubMenu function. 2). Generate a next pattern using the setNextGenList function. 3). Copy the tempGen to the currentGen using the copyList function. 4). Print the currentGen using the displayList function. g. When the user presses S, it will terminate the loop in step f, and reset the screen to the 'U' pattern. h. When the user presses Q, it will terminate the program.

***Define the functions in the beginning, not in the middle of your code.

***No object-oriented programming.

OUTPUT:

image text in transcribedimage text in transcribedimage text in transcribed

[P]lay - Press 'P' to play. [Qluit - Press 'Q' to exit. 000000000000000000000000000000000000010000010000000000000000 000000000000000000000000000000000000010000010000000000000000 000000000000000000000000000000000000010000010000000000000000 000000000000000000000000000000000000010000010000000000000000 000000000000000000000000000000000000010000010000000000000000 000000000000000000000000000000000000011111110000000000000000

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

Step: 3

blur-text-image

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions