Passiday / OOP-Cards

Library for card games
4 stars 8 forks source link

Added toString() and log() method to CardSet class #9

Closed towergame closed 4 years ago

towergame commented 4 years ago

Also fixed the toString() method in Card class, since I forgot how cards work.

sakars commented 4 years ago

@Passiday this completes task 3 in projects I suggest we move that card to "in progress"

towergame commented 4 years ago

case 1: return "A" + this.getSuitSymbol(); here and in other places replace with static constants for readibility (see CukasGame)

Is this what you had in mind?

sakars commented 4 years ago

case 1: return "A" + this.getSuitSymbol(); here and in other places replace with static constants for readibility (see CukasGame)

Is this what you had in mind?

Yes exactly

sakars commented 4 years ago

@Passiday this completes task 3 in projects I suggest we move that card to "in progress"

@towergame you can do that too since you are a contributor (i think)

towergame commented 4 years ago

Nope, no permission to edit

Passiday commented 4 years ago

toString() ir īpaša metode, ja objeto piespiež (coerce) konvertēties uz string (piemēram, obj+""), tad tiek netieši pasaukta objekta toString() metode. Tāpēc es sagaidītu, ka tiek izmantots array.join(", "), nevis mahinē ar paštaisītu ciklu.

towergame commented 4 years ago

Njaa, taa iznaak smukaak. Es arii pie viena izdomaaju uztaisiit log() CardSetam, ceru ka labi izskataas jo vajadzeeja kaartiigi palauzt galvu kaa lai panaak ka izmet console tiesi taa, kaa vajag.

Passiday commented 4 years ago

Baigi sarežģītais Tev tas log() tomēr. Var taču vienkārši replace visus sarkanos simbolus ar "%c$&%c", pievienot array tik reizes, cik matchi, divus elementus - "color:red", "color:black" -, un tad pasaukt console log, izmantojot array spread operatoru (var, protams, ar apply, bet ar spread ir coolāk):

let params = ["color:red", "color:black", "color:blue"];
console.log("%cRed %cBlack %cBlue", ...params);
towergame commented 4 years ago

Vajadzeetu tagad buut smukaakam.

Passiday commented 4 years ago

Vispār jau array push() metode pieņem n parametrus, bet Ok :)