Question: Does anyone know how to do task 3? Please provide the code. 255 Task 3: toString 256 Define a function called tostring in class World
255 Task 3: toString 256 Define a function called tostring in class World that returns a string of the form: 257 "0,01Joe (1) (1,0nu11 (0) [0,11Sam (0) 11,1)nu11 (0) 258 Your string should be constructed from the row, column, owner and armies variables 259 260 261 262 associated with each territory. Hint: You should construct the string using string concatenations of the form: string1"+"string2"+variable + "another string". This function must be defined compositionally. That is, each component of the world should 263 also have its own toString0 function that is used by the World toString0 function 264 If you completed up to this point with perfect indentation, you should now have a Part A score of75%. 265 255 Task 3: toString 256 Define a function called tostring in class World that returns a string of the form: 257 "0,01Joe (1) (1,0nu11 (0) [0,11Sam (0) 11,1)nu11 (0) 258 Your string should be constructed from the row, column, owner and armies variables 259 260 261 262 associated with each territory. Hint: You should construct the string using string concatenations of the form: string1"+"string2"+variable + "another string". This function must be defined compositionally. That is, each component of the world should 263 also have its own toString0 function that is used by the World toString0 function 264 If you completed up to this point with perfect indentation, you should now have a Part A score of75%. 265
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
