Created
February 13, 2017 18:40
-
-
Save eduard93/a3f611513a1560007fcedd8bd71c1777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.1 (Build 656U)" ts="2017-02-13 21:37:36"> | |
<Class name="ITPlanet.PlayerTest"> | |
<Abstract>1</Abstract> | |
<TimeChanged>64327,77051.089536</TimeChanged> | |
<TimeCreated>64327,76559.729877</TimeCreated> | |
<Method name="Test"> | |
<Description> | |
Тестовый пример. Создаёт доску scrabble и посылает её игроку | |
do ##class(ITPlanet.Player).Test()</Description> | |
<ClassMethod>1</ClassMethod> | |
<FormalSpec>Letters:%String(MAXLEN=7)="abc*atd"</FormalSpec> | |
<Implementation><![CDATA[ | |
// Set Board(RowNum, ColNum) = Letter | |
Set Board(8, 4) = "i" | |
Set Board(8, 5) = "t" | |
Set Board(8, 6) = "p" | |
Set Board(8, 7) = "l" | |
Set Board(8, 8) = "a" | |
Set Board(8, 9) = "n" | |
Set Board(8, 10) = "e" | |
Set Board(8, 11) = "t" | |
// Отобразить состояние доски | |
Do ..DisplayBoard(.Board) | |
Do ##class(ITPlanet.Player).Move(.Board, Letters) | |
// Для проверки можно посмотреть сколько очков набрало ваше слово | |
Set word = "cat" | |
Write word, ": ", ..GetPoints(word),! | |
Do ..DisplayBoard(.Board) | |
]]></Implementation> | |
</Method> | |
<Method name="DisplayBoard"> | |
<Description> | |
Нарисовать доску</Description> | |
<ClassMethod>1</ClassMethod> | |
<FormalSpec><![CDATA[&Board]]></FormalSpec> | |
<Implementation><![CDATA[ | |
Write " _______________",! | |
For i=1:1:15 { | |
Write "|" | |
For j=1:1:15 { | |
Write $Get(Board(i,j), " ") | |
} | |
Write "|",! | |
} | |
Write " _______________",! | |
]]></Implementation> | |
</Method> | |
<Method name="GetPoints"> | |
<Description> | |
Число очков за слово</Description> | |
<ClassMethod>1</ClassMethod> | |
<FormalSpec>UsedLetters:%String(MAXLEN=7)</FormalSpec> | |
<ReturnType>%Integer</ReturnType> | |
<Implementation><![CDATA[ | |
Set Points = 0 | |
For i=1:1:$Length(UsedLetters) { | |
Set Points = Points + ..GetLetterPoints($Extract(UsedLetters, i)) | |
} | |
Return Points | |
]]></Implementation> | |
</Method> | |
<Method name="GetLetterPoints"> | |
<Description> | |
Число очков за букву</Description> | |
<ClassMethod>1</ClassMethod> | |
<FormalSpec>Letter:%String(MAXLEN=1)</FormalSpec> | |
<ReturnType>%Integer</ReturnType> | |
<Implementation><![CDATA[ | |
Quit $Select("*"=Letter:0, | |
"eaionrtlsu"[Letter:1, | |
"dg"[Letter:2, | |
"bcmp"[Letter:3, | |
"fhvwy"[Letter:4, | |
"k"=Letter:5, | |
"jx"[Letter:8, | |
"qz"[Letter:10, | |
1:-1000) | |
]]></Implementation> | |
</Method> | |
</Class> | |
</Export> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment