I have a hierarchy that looks like this:
attribute player attribute Player1 player Enhances the feature player provides player features in player 2 Human Player Extends Feature Extends Computer Expands Player
I have a function literally That will map user input into the example of type players where type players = tupl 2 [Player1 , Player2] : val initialize: array [string] = & gt; Player = (args: array [string]) => Args.map (_ trim.toLowerCase) match {case array ("x") = & gt; (New player with human 1, new player with computer 2) case array ("o") = & gt; (New player 1 with computer, new player with human 2) case _ = & gt; (New player with manual 1, new player 2 with computer)} Is there any way I can tell my other classes about the player Can you finish all? E.g. def next player (player: player) (players in player: player): player = player match {case_: player1 = & gt; Player._2 case_: player2 = & gt; Players ._1} I want to avoid the opposite side effects as much as I can, so I have not done anything like this:
object gamestate {var Player1: player = _ var player2: player = _} although it would be the only way to be to pass player in all ways?
Embed individual players within a player class: Class players (init: Array [String]) {players = & gt; Specialty Players ... Val (P1, P2) = init.map (_Tim.toLowerCase Match {Case Array ("x") => (New Player with Human 1, New Player 2 with Human ) ... def nextPlayer (player: player): player = if (player one p1) p2 and p1 ...}
No comments:
Post a Comment