Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP! SOMEONE IN CS1331!! I'M SO DESPERATE. Write a GUI program in a file named ChessGui.java that displays the metadata of ChessGames, one per

PLEASE HELP! SOMEONE IN CS1331!! I'M SO DESPERATE.

Write a GUI program in a file named ChessGui.java that displays the metadata of ChessGames, one per line, of each game in ChessDb in a TableView. In the bottom of the main screen should be two buttons: View and Dismiss. View should be disabled if no game is selected in the table. If a game is selected, View should be enabled and, when clicked, should show a dialog box with the metadata and moves of the selected game. This dialog may be as simple as you wish. Dismiss should exit the program. Your main screen should look something like this:

image text in transcribed

Add a search feature to your GUI that allows the user to search for games by a specific player, or games that Black won, or any other useful thing you can think of.

Add a field for Opening to ChessGame that is automatically calculated from the moves of the game. In addition to any games you add in the step below, recognize the following openings: Giuoco Piano, Ruy Lopez, Sicilian Defence, Queens Gambit, Indian Defence, and Philidor Defence

write a PGN reader and incorporate it into your GUI so that, in addition to the games in ChessDb, all the games in PGN files in the same directory as your ChessGui are also displayed in the table. Also submit your test PGN files.

ChessGame.java

import java.util.ArrayList; import java.util.List; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty;

public class ChessGame {

private StringProperty event = new SimpleStringProperty(this, "NA"); private StringProperty site = new SimpleStringProperty(this, "NA"); private StringProperty date = new SimpleStringProperty(this, "NA"); private StringProperty white = new SimpleStringProperty(this, "NA"); private StringProperty black = new SimpleStringProperty(this, "NA"); private StringProperty result = new SimpleStringProperty(this, "NA"); private List moves;

public ChessGame(String event, String site, String date, String white, String black, String result) { this.event.set(event); this.site.set(site); this.date.set(date); this.white.set(white); this.black.set(black); this.result.set(result); moves = new ArrayList(); }

public void addMove(String move) { moves.add(move); }

public String getMove(int n) { return moves.get(n - 1); }

public String getEvent() { return event.get(); }

public String getSite() { return site.get(); }

public String getDate() { return date.get(); }

public String getWhite() { return white.get(); }

public String getBlack() { return black.get(); }

public String getResult() { return result.get(); } }

ChessDb.java

import java.util.ArrayList; import java.util.List;

public class ChessDb {

private List games;

public ChessDb() { games = new ArrayList(); games.add(morphyIsouard()); games.add(talFischer()); }

public List getGames() { return games; }

private ChessGame morphyIsouard() { ChessGame game = new ChessGame( "A Night at the Opera", "Paris Opera House", "1958.01.01", "Morphy, Paul", "Comte Isouard de Vauvenargues and Karl II, Duke of Brunswick", "1-0" ); game.addMove("e4 e5"); game.addMove("Nf3 d6"); game.addMove("d4 Bg4"); game.addMove("dxe5 Bxf3"); game.addMove("Qxf3 dxe5"); game.addMove("Bc4 Nf6"); game.addMove("Qb3 Qe7"); game.addMove("Nc3 c6"); game.addMove("Bg5 b5"); game.addMove("Nxb5 cxb5"); game.addMove("Bxb5+ Nbd7"); game.addMove("O-O-O Rd8"); game.addMove("Rxd7 Rxd7"); game.addMove("Rd1 Qe6"); game.addMove("Bxd7+ Nxd7"); game.addMove("Qb8+ Nxb8"); game.addMove("Rd8#"); return game; }

private ChessGame talFischer() { ChessGame game = new ChessGame( "Bled-Zagreb-Belgrade Candidates", "Bled, Zagreb & Belgrade YUG", "1959.10.11", "Tal, Mikhail", "Fischer, Robert James", "1-0" ); game.addMove("d4 Nf6"); game.addMove("c4 g6"); game.addMove("Nc3 Bg7"); game.addMove("e4 d6"); game.addMove("Be2 O-O"); game.addMove("Nf3 e5"); game.addMove("d5 Nbd7"); game.addMove("Bg5 h6"); game.addMove("Bh4 a6"); game.addMove("O-O Qe8"); game.addMove("Nd2 Nh7"); game.addMove("b4 Bf6"); game.addMove("Bxf6 Nhxf6"); game.addMove("Nb3 Qe7"); game.addMove("Qd2 Kh7"); game.addMove("Qe3 Ng8"); game.addMove("c5 f5"); game.addMove("exf5 gxf5"); game.addMove("f4 exf4"); game.addMove("Qxf4 dxc5"); game.addMove("Bd3 cxb4"); game.addMove("Rae1 Qf6"); game.addMove("Re6 Qxc3"); game.addMove("Bxf5+ Rxf5"); game.addMove("Qxf5+ Kh8"); game.addMove("Rf3 Qb2"); game.addMove("Re8 Nf6"); game.addMove("Qxf6+ Qxf6"); game.addMove("Rxf6 Kg7"); game.addMove("Rff8 Ne7"); game.addMove("Na5 h5"); game.addMove("h4 Rb8"); game.addMove("Nc4 b5"); game.addMove("Ne5 1-0"); return game;

} }

Ghess DB GU Date White Black Result Event Site Bled-Zagreb-Belgrade.. Bled, Zagreb & Be. 1959.10.11 Ta ki Fischer, Robert James 1-0 A Night at the Opera Paris Opera House 1958.01.01 Morphy, Paul Comte Isouard de Vauv... 1-0 View Game Dismiss

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions