Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10616)

Issue 238190043: ShadPython - 4 - Fabarisov Dmitriy - AD

Can't Edit
Can't Publish+Mail
Start Review
Created:
8 years, 11 months ago by brain2805
Modified:
8 years, 11 months ago
Reviewers:
shad.python
Visibility:
Public.

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -0 lines) Patch
M animal.py View 1 chunk +1 line, -0 lines 0 comments Download
M main.py View 1 chunk +1 line, -0 lines 1 comment Download
M ocean.py View 1 chunk +1 line, -0 lines 1 comment Download
M predator.py View 1 chunk +1 line, -0 lines 0 comments Download
M prey.py View 1 chunk +1 line, -0 lines 0 comments Download
M test_main.py View 1 chunk +1 line, -0 lines 0 comments Download
M test_ocean.py View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 1
shad.python
8 years, 11 months ago (2015-05-20 16:18:21 UTC) #1
Помимо комментариев в коде, сложновата логика в Predator::Move / Prey::Move,
кажется можно проще.

https://codereview.appspot.com/238190043/diff/1/main.py
File main.py (left):

https://codereview.appspot.com/238190043/diff/1/main.py#oldcode72
main.py:72: obstacles.append([x, y])
Из-за такой разницы в добавляемых объектах вам приходится мудрить в классе
Ocean. Проще сделать некий класс Cell, представляющий ячейку, и отнаследовать от
него Animal, Predator(Animal), Prey(Animal), Obstacle и Empty, причем координаты
(x,y) будут присутствовать в базовом классе Cell. 

И заодно не придется писать код, который идет ниже в блоке else.

https://codereview.appspot.com/238190043/diff/1/ocean.py
File ocean.py (left):

https://codereview.appspot.com/238190043/diff/1/ocean.py#oldcode65
ocean.py:65: predator.move(self)
Объект Ocean наверное может понадобиться и в других методах класса Predator.
Поэтому я бы его передавал при инициализации объекта класса Predator.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b