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

Method getHeadStr

javascript_games/ducklings.js:104–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 }
103
104 getHeadStr() {
105 // Returns the string of the duckling's head.
106 let headStr = '';
107 if (this.direction === LEFT) {
108 // Get the mouth:
109 if (this.mouth === OPEN) {
110 headStr += '>';
111 } else if (this.mouth === CLOSED) {
112 headStr += '=';
113 }
114
115 // Get the eyes:
116 if (this.eyes === BEADY && this.body === CHUBBY) {
117 headStr += '"';
118 } else if (this.eyes === BEADY && this.body === VERY_CHUBBY) {
119 headStr += '" ';
120 } else if (this.eyes === WIDE) {
121 headStr += "''";
122 } else if (this.eyes === HAPPY) {
123 headStr += '^^';
124 } else if (this.eyes === ALOOF) {
125 headStr += '``';
126 }
127
128 headStr += ') '; // Get the back of the head.
129 }
130
131 if (this.direction === RIGHT) {
132 headStr += ' ('; // Get the back of the head.
133
134 // Get the eyes:
135 if (this.eyes === BEADY && this.body === CHUBBY) {
136 headStr += '"';
137 } else if (this.eyes === BEADY && this.body === VERY_CHUBBY) {
138 headStr += ' "';
139 } else if (this.eyes === WIDE) {
140 headStr += "''";
141 } else if (this.eyes === HAPPY) {
142 headStr += '^^';
143 } else if (this.eyes === ALOOF) {
144 headStr += '``';
145 }
146
147 // Get the mouth:
148 if (this.mouth === OPEN) {
149 headStr += '<';
150 } else if (this.mouth === CLOSED) {
151 headStr += '=';
152 }
153 }
154
155 if (this.body === CHUBBY) {
156 // Get an extra space so chubby ducklings are the same
157 // width as very chubby ducklings.
158 headStr += ' ';
159 }
160
161 return headStr;

Callers 1

getNextBodyPartMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected