mircea stefanescu

Greenhorn
+ Follow
since May 31, 2021
Cows and Likes
Cows
Total received
1
In last 30 days
1
Total given
0
Likes
Total received
1
Received in last 30 days
1
Total given
5
Given in last 30 days
5
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mircea stefanescu

[Hi, I didn't make a class, I tried to keep the structure as it is;
I try not to complicate myself with the new class.
0 based numers...
1 week ago
I have the following problem:

We consider a deck of playing cards in the following format:
Ranks: 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A
Suits: S - Spade, D - Diamond, H - Heart, C - Club
Every card will be identified by 2 characters
E.g. "3S" (3 of Spades), "TC" (10 of Club), "AH" (Ace of Heart)

I want to implement a method that returns a stream as follows:
- every cards is mapped to its ranking (2 of any rank -> 1, 3 of any rank -> 2, ...
T of any rank -> 9, ... A of any rank -> 13)
- the ranks are sorted ascending
- the function calls the previous method to print the ranks
(the Stream received as parameter contains cards in the same format as before)
E.g. For a stream containing "3S, "TC", "AH" the function should return "2 9 13"
1 week ago

mircea stefanescu wrote:

mircea stefanescu wrote:

Carey Brown wrote:Mircea has yet to tell us what class we are designing so, so far, everything's been static. A "Card" class would be a good place to start.



My design is as follows:

I have a functional interface:



and a Utils class in which I implement different methods, anonymous classes.
So far I have this:



Now I'm struggling with the getCardsLowerThanSorted method, which I still haven't been able to implement properly



Here I display the results in main:



I made the following changes ...



but I still can't sort them out properly
1 week ago

mircea stefanescu wrote:

Carey Brown wrote:Mircea has yet to tell us what class we are designing so, so far, everything's been static. A "Card" class would be a good place to start.



My design is as follows:

I have a functional interface:



and a Utils class in which I implement different methods, anonymous classes.
So far I have this:



Now I'm struggling with the getCardsLowerThanSorted method, which I still haven't been able to implement properly



Here I display the results in main:

1 week ago

Carey Brown wrote:Mircea has yet to tell us what class we are designing so, so far, everything's been static. A "Card" class would be a good place to start.



My design is as follows:

I have a functional interface:



and a Utils class in which I implement different methods, anonymous classes.
So far I have this:



Now I'm struggling with the getCardsLowerThanSorted method, which I still haven't been able to implement properly
1 week ago
Now, I want to modify the getCardsLowerThanSorted function in order to return a Stream
with all the cards that are ranked lower than the rank received as parameter

Additionally they should be sorted in the following manner:
- first all the cards of Spade by rank ascending
- then all the cards of Diamond by rank ascending
- then all the cards of Heart by rank ascending
- finally all the cards of Club by rank ascending

1 week ago

Campbell Ritchie wrote:

mircea stefanescu wrote:. . .
I had to use .limit (3)

Please use limit(3L) because the parameter taken is a long. Why do you have to reduce your Stream to a maximum of 3?



There are some requirements that I am trying to solve in an attempt to become a better Java programmer.
1 week ago

mircea stefanescu wrote:

Carey Brown wrote:Sorting by rank.



Hi, both codes are good but the idea is that I want them to show me the first 3 values ​​in the list.
How can I do that?



I found in the meantime,
I had to use .limit (3)
1 week ago

Carey Brown wrote:Sorting by rank.



Hi, both codes are good but the idea is that I want them to show me the first 3 values ​​in the list.
How can I do that?
1 week ago
How to modify the getCardsLowerThan function in order to return a Stream with all the cards that are ranked lower than the rank received as parameter ?

I tried this but it's not the right code

1 week ago
Thank you , I succeeded
1 week ago

Campbell Ritchie wrote:Please tell us what went wrong. The rank isn't at index 1; it is index 0.
This is the problem with using Strings, as I said in your other thread. If you used the same technique as in the JLS, you would have exactly 52 Card objects and there would be no need to use distinct(). Note the example in the JLS uses the suits in the order conventionally used in Bridge: ♣<<<♠. It just so happens that the English names of the suits are in the same order alphabetically, but in other languages you would need to create a Comparator<Card> by suit name. In German the four suits are ♣=Kreuz, =Karo, =Herz, and ♠=Pik.




I understand what you said, but these are the conditions under which I want to implement the method
1 week ago
How can I modify getCardsByRank function in order to return a Stream
with all the DISTINCT cards of that rank,
alphabetically SORTED ?

E.g. for a list that contains "2H", "2S", "TH" and the rank is '2'
the result should be a stream containing "2H" and "2S" in this order.

I have tried this:




but it did not work...
1 week ago


We consider a deck of playing cards in the following format:

Ranks: 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A

Suits: S - Spade, D - Diamond, H - Heart, C - Club

Every card will be identified by 2 characters
E.g. "3S" (3 of Spades), "TC" (10 of Club), "AH" (Ace of Heart).

I want to modify the getCardsBySuit function in order to return a Stream with all the cards belonging to that suit.

E.g. for a list that contains "2H", "3S", "TH" and the suit is 'H', the result should be a stream containing "2H" and "TH"

1 week ago