質問編集履歴

1

コードが読めるように修正しました

2017/11/19 14:19

投稿

an6
an6

スコア20

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,8 @@
5
5
  どうぞよろしくお願い致します。
6
6
 
7
7
 
8
+
9
+ ```ここに言語を入力
8
10
 
9
11
  class Location(object):
10
12
 
@@ -22,7 +24,31 @@
22
24
 
23
25
 
24
26
 
27
+ def getX(self):
28
+
25
- 〜中略〜
29
+ self.x
30
+
31
+
32
+
33
+ def getY(self):
34
+
35
+ self.y
36
+
37
+
38
+
39
+ def distFrom(self,other):
40
+
41
+ ox,oy=other.x, other.y
42
+
43
+ xDist, yDist=self.x-ox, self.y-oy
44
+
45
+ return (xDist**2+yDist**2)**0.5
46
+
47
+
48
+
49
+ def __str__(self):
50
+
51
+ return '<'+str(self.x)+', '+str(self.y)+'>'
26
52
 
27
53
 
28
54
 
@@ -57,3 +83,15 @@
57
83
  currentLocation = self.drunks[drunk]
58
84
 
59
85
  self.drunks[drunk]=currentLocation.move(xDist,yDist)
86
+
87
+
88
+
89
+ def getLoc(self, drunk):
90
+
91
+ if drunk not in self.drunks:
92
+
93
+ raise ValueError('Drunk not in field')
94
+
95
+ return self.drunks[drunk]
96
+
97
+ ```