Lecture4-2 - DataStructures CSCI 132 Spring 2012 Lecture 4...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Data Structures   CSCI 132, Spring 2012 Lecture 4 Implementing Life
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Rules of Life The neighbors of a given cell are the eight cells that touch it. Every cell is either living or dead. A living cell stays alive in the next generation if it has either 2 or 3 living neighbors; otherwise it dies (of loneliness or overcrowding) A dead cell becomes alive in the next generation if it has exactly 3 neighboring cells that are already alive. All births and deaths take place at exactly the same time for each generation.
Image of page 2
3 Specifications We want the program to: List instructions Allow user to initialize grid Print out grid at each generation Update next generation Repeat until user says stop
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Design Class (noun) The Life game itself Methods or functions Print instructions Initialize Print Update
Image of page 4
5 The Client Code #include "utility.h" #include "life.h" int main( ) { Life configuration; instructions( ); configuration.initialize( ); configuration.print( ); cout << " Continue viewing new generations? "<<endl;
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern