Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fp2024:hw3 [2024/05/05 12:03] pdmatei |
fp2024:hw3 [2024/05/08 16:56] (current) pdmatei [Submission rules] |
||
---|---|---|---|
Line 36: | Line 36: | ||
==== Coding tasks ==== | ==== Coding tasks ==== | ||
- | **1.** Boards will be represented using the class ''Board'' (see the project template), which contains a board matrix, as well as the player whose turn it is to play. In order to create a board, write a function which converts a string into a ''Board''. Implement the apply method in the companion object ''Board''. As a helper, you can use ''_.split( c )'' where c is a separator string, and ''_.toList''. The best solution is to use a combination of ''map'' calls with the above mentioned functions. A string is encoded exactly as in the examples shown above: | + | **1.** Boards will be represented using the class ''Board'' (see the project template), which contains a board matrix, as well as the player whose turn it is to play. You may consider that the first player starts the game. (For testing purposes, you may also create other apply methods). In order to create a board, write a function which converts a string into a ''Board''. Implement the apply method in the companion object ''Board''. As a helper, you can use ''_.split( c )'' where c is a separator string, and ''_.toList''. The best solution is to use a combination of ''map'' calls with the above mentioned functions. A string is encoded exactly as in the examples shown above: |
* there are no whitespaces - empty positions are marked by the character '.' | * there are no whitespaces - empty positions are marked by the character '.' | ||
* lines are delimited by '\n' (the last line does not have a trailing '\n'). | * lines are delimited by '\n' (the last line does not have a trailing '\n'). | ||
Line 88: | Line 88: | ||
**8.** Write a function which checks if the current player is the winner. Hint: functions ''l.forall(_)'' and ''l.exists(_)'' may be very helpful, together with patterns. | **8.** Write a function which checks if the current player is the winner. Hint: functions ''l.forall(_)'' and ''l.exists(_)'' may be very helpful, together with patterns. | ||
<code scala> | <code scala> | ||
- | def winner: Boolean = | + | def winner: Boolean = ??? |
</code> | </code> | ||
Line 116: | Line 116: | ||
===== Submission rules ===== | ===== Submission rules ===== | ||
- | * Please follow the [[fp2023:submission-guidelines| Submission guidelines]] which are the same for all homework. | + | * Please follow the [[fp2024:submission-guidelines| Submission guidelines]] which are the same for all homework. |
- | * To solve your homework, download the {{:fp2023:h3-5-in-a-row.zip|Project template}}, import it in IntellIJ, and you are all set. Do not rename the project manually, as this may cause problems with IntellIJ. | + | * To solve your homework, download the {{:fp2024:hw03-five-in-a-row.zip|Project template}}, import it in IntellIJ, and you are all set. Do not rename the project manually, as this may cause problems with IntellIJ. |