We're going to build a class to enable us to reproduce the following logic for a single cell,
The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if caused by under-population.
- 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 over-population.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Attributes
For just a cell (all we're modelling at this point) there are two obvious attributes
- isAlive - whether the cell is alive or not
- numLiveNeighbours - the number of live neighbours the cell has
Methods - basic
I decided not to bother with complicated constructors and just use the basic one. However I decided to "getter and setter" my attributes (make get and set methods for each). This would allow me to configure a cell as I needed it configured.
Conway's Rules Method
Test it
The following are 3 @Test methods for my class - it really needs a lot more ...
I set up my cell, then assert it's in the state I expect.
The code is available in Github here.
Extension material
Create some more @Tests for this class.
Investment channels that you should not miss online casino
ReplyDeleteG club Online Casino Gambling Sites Betting Style For every gamer, every gambler has access to online gaming investment services at anytime. We also have a variety of online casino games. Every player has access to the services of online casino games with the best.
In addition, we also offer a variety of online betting services. All you gamblers, gamblers, can choose to use the services of online gambling and a lot of fun. And we also have the style of online casino games are the best. One option that bettors can choose at the site. We also have the style of play online gambling lot. Every player has all the options to use the online game investment services and a variety of fun all the time. Gclub มือถือ
I am very glad to read your informative blog...thanks a lot for your valuable sharing
ReplyDeleteyou can also visit here Java Programming in Delhi
ReplyDeleteThanks for sharing this good blog.This is very important and
imformative blog for Java .It's very interesting and useful for students
Core Java Online Training Hyderabad
ReplyDeletesuch a wonderful article...very interesting to read ....thanks for sharining .............
Best Tableau online training in Hyderabad
Tableau online training in Hyderabad
Tableau training in Hyderabad
Nice blog..! I really loved reading through this article. Thanks for sharing such a amazing post with us and keep blogging...
ReplyDeletedata science online training in Hyderabad
best data science online training in MUMBAI
data science training in BENGALORE
Nice blog..! I really loved reading through this article. Thanks for sharing such a amazing post with us and keep blogging...
ReplyDeletedata science online training in Hyderabad
best data science online training in MUMBAI
data science training in BENGALORE
Nice blog. i hope u continue sharing these kind of articles.
ReplyDeletehttp://www.rstrainings.com/adv-java-online-training.html
http://www.rstrainings.com/core-java-online-training.html
NIce blog! thanks for sharing a good information about this article. Java Online Training from Hyderabad India
ReplyDeleteThanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
ReplyDeletemicroservices online training
best microservices online training
top microservices online training
Thank you for your valuable post. It is really helpful. Keep posting.
ReplyDeleteVisit us: Core Java Online Course
Visit us: Best Online Java Course