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
Hide 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 {
...
@@ -6,7 +6,7 @@ export class Card {
this
.
_rank
=
rank
;
this
.
_rank
=
rank
;
this
.
_suite
=
suit
;
this
.
_suite
=
suit
;
}
}
show
(){
show
(
i
:
number
){
return
(
`
_____\n|
${
this
.
_rank
}
${
this
.
_suite
}
|\n
-----`
)
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"
;
import
{
Card
}
from
"./Card"
;
class
Hand
{
export
class
Hand
{
private
limit
:
number
=
5
;
private
_limit
:
number
=
5
;
private
holdingCards
:
Card
[]
=
[];
private
_holdingCards
:
Card
[]
=
[];
private
_changeCounter
:
number
=
5
;
receiveCard
(
card
:
Card
)
{
receiveCard
(
card
:
Card
)
{
if
(
this
.
holdingCards
.
length
<=
this
.
limit
)
{
if
(
this
.
_holdingCards
.
length
<
this
.
_
limit
)
{
this
.
holdingCards
.
push
(
card
)
this
.
_
holdingCards
.
push
(
card
)
}
else
{
}
else
{
console
.
log
(
"Hand is full!"
)
console
.
log
(
"Hand is full!"
)
}
}
}
}
showCards
(){
showCards
(){
for
(
let
i
=
0
;
i
<
this
.
holdingCards
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
_
holdingCards
.
length
;
i
++
){
console
.
log
(
`Card#
${
i
}
) `
)
console
.
log
(
this
.
_holdingCards
[
i
].
show
(
i
+
1
)
)
this
.
holdingCards
[
i
].
show
();
console
.
log
(
"=============="
)
}
}
}
}
changeCard
(
newCard
:
Card
,
i
:
number
){
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