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
be83115b
Commit
be83115b
authored
Mar 20, 2024
by
Chingiz
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Class Hand has been created and some changes has been made in the Card class
parent
6117d857
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
Card.ts
src/Modules/Card.ts
+2
-2
Hand.ts
src/Modules/Hand.ts
+17
-9
No files found.
src/Modules/Card.ts
View file @
be83115b
...
...
@@ -6,7 +6,7 @@ export class Card {
this
.
_rank
=
rank
;
this
.
_suite
=
suit
;
}
show
(){
return
(
`
_____\n|
${
this
.
_rank
}
${
this
.
_suite
}
|\n
-----`
)
show
(
i
:
number
){
return
(
`
_____\n
${
i
}
|
${
this
.
_rank
}
${
this
.
_suite
}
|\n
-----`
)
}
}
\ No newline at end of file
src/Modules/Hand.ts
View file @
be83115b
import
{
Card
}
from
"./Card"
;
class
Hand
{
private
limit
:
number
=
5
;
private
holdingCards
:
Card
[]
=
[];
export
class
Hand
{
private
_limit
:
number
=
5
;
private
_holdingCards
:
Card
[]
=
[];
private
_changeCounter
:
number
=
5
;
receiveCard
(
card
:
Card
)
{
if
(
this
.
holdingCards
.
length
<=
this
.
limit
)
{
this
.
holdingCards
.
push
(
card
)
if
(
this
.
_holdingCards
.
length
<
this
.
_
limit
)
{
this
.
_
holdingCards
.
push
(
card
)
}
else
{
console
.
log
(
"Hand is full!"
)
}
}
showCards
(){
for
(
let
i
=
0
;
i
<
this
.
holdingCards
.
length
;
i
++
){
console
.
log
(
`Card#
${
i
}
) `
)
this
.
holdingCards
[
i
].
show
();
for
(
let
i
=
0
;
i
<
this
.
_
holdingCards
.
length
;
i
++
){
console
.
log
(
this
.
_holdingCards
[
i
].
show
(
i
+
1
)
)
console
.
log
(
"=============="
)
}
}
changeCard
(
newCard
:
Card
,
i
:
number
){
this
.
holdingCards
[
i
]
=
newCard
;
if
(
i
>
6
&&
i
>
0
)
return
console
.
log
(
"Card number can not be more then 5 and less then 1"
)
if
(
this
.
_changeCounter
){
this
.
_holdingCards
[
i
-
1
]
=
newCard
;
console
.
log
(
"Card has been changed!"
)
this
.
_changeCounter
--
}
else
{
console
.
log
(
"You've already changed 5 times."
)
}
}
}
\ 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