lyudaio / jcards Goto Github PK
View Code? Open in Web Editor NEWjCards is a lightweight Java library for creating and manipulating playing cards
Home Page: https://jcards.lyuda.io
License: MIT License
jCards is a lightweight Java library for creating and manipulating playing cards
Home Page: https://jcards.lyuda.io
License: MIT License
Methods that throw
exceptions have to have their Exceptions declared in the method header, e.g.
public Card(Rank rank, Suit suit) throws IllegalStateException {
if (rank == null) {
throw new IllegalArgumentException("Rank cannot be null");
}
if (suit == null) {
throw new IllegalArgumentException("Suit cannot be null");
}
this.rank = rank;
this.suit = suit;
}
This goes through the entire codebase in every single method that throws an exception.
compareTo
method in the Deck is fairly meaningless. What game would need to compare sizes of decks?cardsRemaining
and getSize
methods do essentially the same. One of them is unnecessary.Different issue because the following are feature suggestions.
Please validate the suggestion against your view on the project. Chances are you keep it simple and narrow-scoped for a reason.
But I noticed, that it would be not so complicated to change classes like Hand, Deck etc to support generic types, and change Card type to be an interface. Typical playing cards (hearths, spades etc) could still be provided as an implementation provided by a library.
It would allow users to supply their own implementations opening up the project for other types of card games (like TCG games like Magic the Gathering).
Hello
It looks like the minimum Java version for this project is 19.
I suggest setting the minimum required version to 17, as it is the latest LTS version.
More about versions here https://en.wikipedia.org/wiki/Java_version_history
testShuffle could theoretically fail if both decks were randomly shuffled into the same order
testFindCard should probably assert that the correct card was in fact found, rather than just that the returned index is between 0 and 51
Hey,
not all card games use a standard deck of cards. Some might use different cards that can have different ranks: https://en.wikipedia.org/wiki/Tapp_Tarock
We could generify enums Rank
and Suit
so that we would convert them to interfaces that would only contain getters and other methods that Rank
/Suit
needs and then we would "implement" these interfaces for different types of ranks and suites. The current enum Rank
would then be named like standard French rank etc.
I can help with implementation if you find this useful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.