MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / getBodyStr

Method getBodyStr

javascript_games/ducklings.js:164–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162 }
163
164 getBodyStr() {
165 // Returns the string of the duckling's body.
166 let bodyStr = '('; // Get the left side of the body.
167 if (this.direction === LEFT) {
168 // Get the interior body space:
169 if (this.body === CHUBBY) {
170 bodyStr += ' ';
171 } else if (this.body === VERY_CHUBBY) {
172 bodyStr += ' ';
173 }
174
175 // Get the wing:
176 if (this.wing === OUT) {
177 bodyStr += '>';
178 } else if (this.wing === UP) {
179 bodyStr += '^';
180 } else if (this.wing === DOWN) {
181 bodyStr += 'v';
182 }
183 }
184
185 if (this.direction === RIGHT) {
186 // Get the wing:
187 if (this.wing === OUT) {
188 bodyStr += '<';
189 } else if (this.wing === UP) {
190 bodyStr += '^';
191 } else if (this.wing === DOWN) {
192 bodyStr += 'v';
193 }
194
195 // Get the interior body space:
196 if (this.body === CHUBBY) {
197 bodyStr += ' ';
198 } else if (this.body === VERY_CHUBBY) {
199 bodyStr += ' ';
200 }
201 }
202
203 bodyStr += ')'; // Get the right side of the body.
204
205 if (this.body === CHUBBY) {
206 // Get an extra space so chubby ducklings are the same
207 // width as very chubby ducklings.
208 bodyStr += ' ';
209 }
210
211 return bodyStr;
212 }
213
214 getFeetStr() {
215 // Returns the string of the duckling's feet.

Callers 1

getNextBodyPartMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected