добавлен код с дз по постановке кораблей по размеру

This commit is contained in:
ehermakov 2024-06-03 17:13:18 +03:00
parent a2bc915a4a
commit dd539555b9
3 changed files with 14 additions and 12 deletions

View File

@ -5,9 +5,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока"> <list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ShipView.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipView.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ShipField.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipField.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -38,17 +37,17 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Python.ShipField.executor": "Run", &quot;Python.ShipField.executor&quot;: &quot;Run&quot;,
"Python.main (1).executor": "Run", &quot;Python.main (1).executor&quot;: &quot;Run&quot;,
"Python.main.executor": "Debug", &quot;Python.main.executor&quot;: &quot;Debug&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"last_opened_file_path": "Y:/Downloads/временный гит/hnc-eduard/HNS/Excercises/ShipCraft/Переделка" &quot;last_opened_file_path&quot;: &quot;Y:/Downloads/временный гит/hnc-eduard/HNS/Excercises/ShipCraft/Переделка&quot;
} }
}]]></component> }</component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python.main">
<configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Переделка" /> <module name="Переделка" />

View File

@ -110,6 +110,9 @@ class ShipField:
self.ships.remove(self.ship_size) self.ships.remove(self.ship_size)
self.print_field() self.print_field()
if self.ship_size not in self.ships and len(self.ships) > 0:
self.ship_size = max(self.ships)
def get_ship(self, row, col): def get_ship(self, row, col):
if row < 0 or row > ShipField.field_size: if row < 0 or row > ShipField.field_size:
return return