This semester we returned to teaching Java properly in the first year of our degree programmes, after a couple of years where it was very much a junior partner to C++. We didn’t have time to cover many of the more advanced features of the language, but I thought I’d give the keener students the opportunity to explore for themselves, so for the final piece of coursework I gave them an opportunity to learn and use JavaFX.

The goal was to simulate the card game Baccarat. I gave the students a couple of classes to represent generic playing cards and collections of those cards, and their first task was to extend these by inheritance, creating new classes to represent a card in Baccarat, a hand of these cards and the ‘shoe’ of cards used the dealer. Then they had to use these classes to create a realistic terminal-based simulation of the game. Most stopped there, but a dozen brave souls took up the challenge to create a GUI for the game.

Here’s what one of the solutions looked like. It isn’t the prettiest of the submissions, but a nice feature was the explanation given on-screen of how the decisions about dealing cards were made.

Other solutions were much more polished—from a visual perspective, at least:

Part of the challenge (and part of the fun) was to create some interesting animation effects for the dealing of cards. Here is one student’s solution:

Here’s another one, this time implementing a nice rotation effect:


comments powered by Disqus