Code Monkey home page Code Monkey logo

solitaire's Introduction

Solitaire

Implementation of the Solitaire card game with JavaFX

Demonstration application used in the book Introduction to Software Design with Java.

Building this application

This repository is configured to build automatically in Eclipse with Java 21 and JavaFX 21.

However, when first imported, the project will show a compilation error because the JavaFX dependency is missing.

To add JavaFX:

  1. Download JavaFX 21;
  2. Create a new User Library under Eclipse -> Window -> Preferences -> Java -> Build Path -> User Libraries -> New. Name it JavaFX21 and include the jars under the lib folder from the location where you extracted the JavaFX download.

The project should then build properly.

Running this application

Right-click on the project and select Run As -> Java Application. Select Solitaire from the list.

To run the tests, select Run As - > JUnit Test.

There are also two driver programs, Driver and CrashTest, which run the application in headless mode (that is, without the GUI).

solitaire's People

Contributors

chirontt avatar prmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

solitaire's Issues

Update Style Rules

Adapt the style file to the latest version of Checkstyle and add new rules as appropriate.

Retire the use of the Singleton pattern for GameModel

The GameModel is currently a Singleton. This hinders the use of dependency injection with this instance, and makes testing more complex. Instead, we can still have just one instance of this object, without it being globally available by only initializing it in the application's start method.

Initialize Project

Set up the project classpath, tools, configuration, with a first cut at the code.

Fix Checkstyle style sheet for version 8.44

<module name="JavadocMethod">
  <property name="scope" value="protected"/>
</module>

under the TreeWalker module, due to a breaking change in checkstyle 8.42 (8.44 is latest) this should now be

<module name="JavadocMethod">
  <property name="accessModifiers" value="public, protected"/>
</module>

Port to Java 21

Update the build configuration and, as applicable, leverage new language features.

Create Game Model

Create a singleton class in charge of tracking and managing game state.

JUnit libraries in module-info.java?

@prmr
Why are the JUnit libraries required in the application's module-info.java file? They should not be there in the main application's module.

requires static org.junit.jupiter.api;
requires static org.junit.jupiter.params;

I've got some changes to the .classpath file to remove them and still make Eclipse happy. Are you interested? Or should they be left as an exercise for your students?

HashMap creation per mouse event

This line: ClipboardContent content = new ClipboardContent();

I think it would be okay to have this as a private final global variable and reuse it with each motion event

putString calls

public final boolean putString(String s) {
	if (s == null) {
		remove(DataFormat.PLAIN_TEXT);
	} else {
		put(DataFormat.PLAIN_TEXT, s);
	}
	return true;
}

so the old content will be removed anyways

Change Terminology and Extract Index Enums

Use classic Solitaire-Patience terminology of FoundationPiles and Tableaux instead of "StackManager". Move index enums to top level types.

Rationale: Clarify the design to align it with domain concepts.

Additional design improvements.

Implement Autodraw feature

Whenever the state of the game reaches a point where the discard pile is empty, a new card should automatically be drawn from the deck. This will save one automatic move from the human player.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.