Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hw-49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chingiz
hw-49
Commits
856b3887
Commit
856b3887
authored
Mar 21, 2024
by
Chingiz
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Application.ts has been created.
parent
188100be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
Application.ts
src/Modules/Application.ts
+73
-0
No files found.
src/Modules/Application.ts
0 → 100644
View file @
856b3887
import
*
as
readlineSync
from
'readline-sync'
;
import
{
Deck
}
from
"./Deck"
;
import
{
Hand
}
from
"./Hand"
;
import
{
Checker
}
from
"./Checker"
;
export
class
Application
{
private
_hand
:
Hand
=
new
Hand
()
private
_deck
:
Deck
=
new
Deck
()
startGame
()
{
console
.
log
(
'=============================='
);
console
.
log
(
'Let the Game begin!'
)
console
.
log
(
'==============================
\
n
\
n'
);
let
isEnd
:
boolean
=
true
;
while
(
isEnd
){
const
answer
=
readlineSync
.
question
(
`
Choose one of the options:
1) Shuffle the deck
2) Take five cards
${
this
.
_hand
.
holdingCards
.
join
()
?
'
\
n 3) Show my cards
\
n 4) Change the cards
\
n 5) Show my points'
:
''
}
6) Start new game
7) End this game
`
)
switch
(
answer
)
{
case
'1'
:
this
.
_deck
.
shuffleDeck
()
break
;
case
'2'
:
this
.
spreadOut5Cards
()
break
;
case
'3'
:
this
.
_hand
.
showCards
();
break
;
case
'4'
:
this
.
changeTheCards
()
break
;
case
'5'
:
this
.
checkPoints
()
break
;
case
'6'
:
this
.
_hand
.
holdingCards
=
[];
break
;
case
'7'
:
isEnd
=
false
;
break
;
default
:
console
.
log
(
"Choose correct option!"
)
}
}
}
spreadOut5Cards
(){
for
(
let
i
=
1
;
i
<
6
;
i
++
){
let
cardFromDeck
=
this
.
_deck
.
takeACardFromDeck
();
if
(
cardFromDeck
)
this
.
_hand
.
receiveCard
(
cardFromDeck
);
}
}
changeTheCards
(){
const
answer
=
readlineSync
.
question
(
"Choose which cards you want to change?"
)
const
arrAnswer
=
Array
.
from
(
answer
);
for
(
let
i
=
0
;
i
<
arrAnswer
.
length
;
i
++
)
{
let
cardFromDeck
=
this
.
_deck
.
takeACardFromDeck
();
if
(
cardFromDeck
)
this
.
_hand
.
changeCard
(
cardFromDeck
,
parseInt
(
arrAnswer
[
i
]));
}
}
checkPoints
(){
const
checker
=
new
Checker
(
this
.
_hand
.
holdingCards
)
checker
.
checkCombination
()
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment