Java代写 | Assignment 1.1 – Extending Your Chess Library

本次Java代写是拓展国际象棋游戏
Assignment 1.1 – Extending Your Chess Library
Overview
This week, we will be focusing on refactoring your code from last week, adding good documentation, and also extending your library by adding two custom
pieces and the controller component of MVC. Refactoring your library code and adding good documentation now – and throughout the assignment 1.X – will
allow for easier and more efficient development in the coming weeks. By the end of the week, you should have a clean, easy-to-understand, and
extensible library.
For this assignment, you are required to use either Eclipse or IntelliJ IDEA. Both are free and have powerful refactoring tools available.
Read this entire page before beginning your assignment, and post on Piazza if anything is still unclear.
Part I: Refactoring & Polishing Test Suite
Read here and here for further discussion about this topic.
You spent Assignment 1.0 (Due 19:00 CDT on Feb 9th, 2020) making it work, now you will:
Refactor your code to make it right.
Make it faster by using proper data structures.
Before you begin refactoring, consider your test suite from Assignment 1.0 (Due 19:00 CDT on Feb 9th, 2020). Did your moderator, the TAs, or your peers
from the discussion section suggest ways to improve the coverage of your test suite? Yes, yes you should have written your tests before implementing
your functionality last week, but if for whatever reason, your test suite could be more thorough, spend some time enriching your test suite before you begin
refactoring. Doing so will help you refactor more quickly, and to be more confident in the correctness of your refactorings.
If you have not already done so, consider using a code coverage tool such as EclEmma for Eclipse, or the integrated code coverage features in IntelliJ
IDEA to quantify how thorough your test suite truly is.
You should refactor your code to eliminate any code smells (e.g. use communicative naming, decompose larger methods into smaller separate methods,
etc), add missing tests, or other problems discussed in section.
Part II: Auto-generate Documentation
Next, use Doxygen to auto-generate documentation for your library. You can find pre-packaged binaries here, or run the following command on the EWS
machines or other Linux distros to get the latest build of Doxygen. I will assume this is run from the root directory of your project:
wget http://doxygen.nl/files/doxygen-1.8.16.linux.bin.tar.gz && tar xf doxygen-1.8.2.linux.bin.tar.gz && cp doxygen-1.8.2/bin/doxygen
./ && rm doxygen-1.8.2.linux.bin.tar.gz && rm -rf doxygen-1.8.2
Then, to automatically configure and generate documentation for your project, simply run the following:
1. Run chmod a+rx doxygen && ./doxygen -g
2. Modify Doxyfile line 688, and change RECURSIVE from NO to YES
3. Run ./doxygen Doxyfile
If you have followed the instructions properly, your project directory should now contain autogenerated HTML & latex found under html and latex. Take a
look at html/index.html in a browser to check it out!
This part should be relatively straightforward and is intended to encourage you to expand on the documentation of your public methods and classes.
Imagine you are handing this library to another developer, and that the PDF or HTML generated by Doxygen will be this programmer’s first contact with
your library. Are there any thinly documented areas of the code? It should be more obvious using Doxygen which areas could use further explanation. If
you do see these areas, expand on your documentation, and run Doxygen again to regenerate your documentation.
Assignment Format
This course is likely very different from previous courses you have taken, in that we typically reuse your code from the previous week for each
assignment. As such, don’t waste your time with messy code: focus on maintainability.
Agile Mantra
“Make it work. Make it right. Make it fast.”
Kent Beck
Please do not check your doxygen binary or generated documentation into Gitlab (the _latex, html, or doxygen files). This uses up a tremendous amount
of space and resources in Gitlab and will result in a deduction from Code Submission on the rubric. However, please ensure that Doxyfile, or whatever
configuration file you use to generate your documentation, is committed to Gitlab. Without it, we cannot give you credit for the Doxygen-related
requirements.
Part III: Two Custom Chess Pieces
If your code is properly refactored, this part should be a breeze. Your task is to create two custom chess pieces. All the usual chess rules apply to your
custom pieces, for example, they are not allowed to move outside the board. For simplicity, your custom pieces do not have to implement special moves,
just as we ignored castling for king and rooks. You may find this article from Wikipedia useful, but you are free to create your own movement.
Wikipedia Link: https://en.wikipedia.org/wiki/Fairy_chess_piece
Part IV: Static Terminal OR Graphical User Interface
Useful Link: Model-View-Controller (MVC) Explained Through Ordering Drinks At The Bar
Your task for this part is to implement a STATIC Terminal Interface or a GUI. By static, we mean that your Terminal Interface or your GUI should have ZER
O USER INTERACTION. The only thing required for this week is to display the initial configuration of a chessboard. Do not waste your time
implementing chess moves, you may even lose points if you do. The point of this restriction is to give you a clearer understanding of the MVC
architecture, by strictly separating the Model, View, and Control components. You implemented the chess model last week, this week’s focus is the view.
Simply display a chessboard with the normal set of chess pieces in their initial positions. Keep in mind that this does not mean you can simply display a
static image in your JFrame if you go with the GUI option.
Terminal Interface
You can choose to implement a simple terminal interface for your chess game, something like what is shown in the picture below. We expect that any
feature you implement for the chess game to be implemented as command-line commands. If you choose this option, you will not be eligible for 2 points
extra credit since we consider this an easier task than building a fully fleshed out GUI.
Graphical User Interface
Warning!
If you decide to use the UI builder in Netbeans or IntelliJ for this assignment, be very careful.
Although the UI builder quickly generates Java GUIs, it produces very ugly code that will not meet the requirements for this assignment without
modification. Most noticeably, it tightly couples the view with the controller, so significant refactoring of the autogenerated code will be required. In the
staff’s opinion, it is more work to generate a UI automatically and refactor it properly than to build one from scratch.
Hand written code

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class GUIExample implements ActionListener{
public GUIExample(){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
//silently ignore
}
JFrame window = new JFrame(“Basic Application Example”);
window.setSize(500, 500);
JPanel myPanel = initializePanel();
initializeButton(myPanel);
setUpMenu(window);
window.setContentPane(myPanel);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void initializeButton(JPanel myPanel) {
JButton button = new JButton(“Click me”);
button.addActionListener(this);
myPanel.add(button, BorderLayout.SOUTH);
}
private JPanel initializePanel() {
JPanel myPanel = new JPanel();
myPanel.setPreferredSize(new Dimension(500,500));
myPanel.setLayout(new BorderLayout());
return myPanel;
}
private void setUpMenu(JFrame window) {
JMenuBar menubar = new JMenuBar();
JMenu file = new JMenu(“File”);
JMenuItem open = new JMenuItem(“Open”);
open.addActionListener(this);
file.add(open);
menubar.add(file);
window.setJMenuBar(menubar);
}
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,
“I was clicked by “+e.getActionCommand(),
“Title here”, JOptionPane.INFORMATION_MESSAGE);
}
public static void main(String[] args) {
new GUIExample();
}
}
Netbeans autogenerated code
/*
* GUIExampleView.java
*/
package guiexample;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JOptionPane;
/**
* The application’s main frame.
*/
public class GUIExampleView extends FrameView {
public GUIExampleView(SingleFrameApplication app) {
super(app);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings(“unchecked”)
// <editor-fold defaultstate=”collapsed” desc=”Generated Code”>
private void initComponents() {
mainPanel = new javax.swing.JPanel();
menuBar = new javax.swing.JMenuBar();
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
statusPanel = new javax.swing.JPanel();
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
statusMessageLabel = new javax.swing.JLabel();
statusAnimationLabel = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
mainPanel.setName(“mainPanel”); // NOI18N
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 415, Short.MAX_VALUE)
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 222, Short.MAX_VALUE)
);
menuBar.setName(“menuBar”); // NOI18N
org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(guiexample.GUIExampleApp.class)
.getContext().getResourceMap(GUIExampleView.class);
fileMenu.setText(resourceMap.getString(“fileMenu.text”)); // NOI18N
fileMenu.setName(“fileMenu”); // NOI18N
exitMenuItem.setText(resourceMap.getString(“exitMenuItem.text”)); // NOI18N
exitMenuItem.setName(“exitMenuItem”); // NOI18N
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitMenuItemActionPerformed(evt);
}
});
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
statusPanel.setName(“statusPanel”); // NOI18N
statusPanelSeparator.setName(“statusPanelSeparator”); // NOI18N
statusMessageLabel.setName(“statusMessageLabel”); // NOI18N
statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName(“statusAnimationLabel”); // NOI18N
jButton1.setText(resourceMap.getString(“jButton1.text”)); // NOI18N
jButton1.setName(“jButton1”); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
statusPanel.setLayout(statusPanelLayout);
statusPanelLayout.setHorizontalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
statusPanelLayout.createSequentialGroup()
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
.addComponent(statusAnimationLabel))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE,
399, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusPanelSeparator))
);
statusPanelLayout.setVerticalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE,
2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusMessageLabel)
.addComponent(statusAnimationLabel))
.addGap(3, 3, 3))
);
setComponent(mainPanel);
setMenuBar(menuBar);
setStatusBar(statusPanel);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, “I was clicked by “+evt.getActionCommand(),
“Title”, JOptionPane.INFORMATION_MESSAGE);
}
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
// Variables declaration – do not modify
private javax.swing.JButton jButton1;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
// End of variables declaration
}
Getting Started
GUI programming can be a potentially daunting experience. Below are some external resources to help get you going. Please start early and come to
office hours or ask questions on Piazza if you are confused. These resources cover more than what you need for implementing a static GUI but keep in
mind NO USER INTERACTION this week.
MVC Wikipedia Article – The Wikipedia article on Model-view-controller architecture.
Sun JAVA GUI Tutorial – Sun’s tutorial on Java GUI programming. This is a great resource since it is straight from the source.
Model/View/Controller GUI – An introduction to the model view controller design scheme. Includes a Java GUI example. Especially relevant is
section 3.1.2.0.1 Warning.
Crash Course in Java GUI – An introduction to Java GUI programming. The links on this site are actually PowerPoint presentations.
Java GUI Examples – A number of examples using JFrame and JButton.
Part V: Manual Test Plan
GUI testing is difficult, especially just with unit tests. This week, in order to test your GUI, write a test plan including screenshots and specific steps for a
human tester to follow – what a tester should do and what he/she should observe. Since your GUI this week is static, the test script should be very simple.
You will be building on this test plan in the coming weeks.
A manual test plan should at least include the following:
Prerequisites: What are the version/tools one needs to have to test your code.
Environment Setup and configurations: How do you set-up your testing environment?
Operations and the results (screen capture with description): Both Successful and unsuccessful (undesirable) operations and results should be
documented
Error messages if any
A concise example here. However, since your project includes some interfaces, it should contain more images and descriptions.
Need help?
First, ask questions on Piazza. If you have a question, there is a pretty good chance someone else has someone and an even better chance that someone
else in the class or one of the TAs will be able to answer it for you. If you are still having a problem, email your moderator or one of the TAs to get advice.
Remember, its best to ask questions early on so they have time to be answered. Don’t wait until the last second to get started then realize that you are
confused. In general, we are flexible with interpretations of the assignment, as long as it does not trivialize any component of the assignment.
Summary
Table of Contents
Reading
The Joel Test: 12 Steps to Better Code
Optional: Code Complete chapter 24: Refactoring
Submission
This assignment is due on 19:00 CDT Feb 16th, 2020. Please be sure to submit in Gitlab, and ask your moderator or TA before the deadline if you
have any questions.
Please make sure you follow the repo naming conventions listed on the piazza.
Please make sure that you create a branch with the name assignment-1.1 and merge it back to the master (while keeping the branch)
Objectives
Clean up any problems in your code for Assignment 1.0, expand your test suite if necessary, and fix any algorithmic shortcomings
Auto-generate documentation for your library
Create Two custom chess pieces
Create a static user interface using the Observer Pattern.
Resources
Design Patterns
Design patterns
Model-View-Controller architecture
Model-View-Controller (MVC) Explained Through Ordering Drinks At The Bar
Observer Pattern
Refactoring
Refactoring
Refactoring in Eclipse
Refactoring in IntelliJ
Grading
Moderators are asked to grade styles according to the progressive rubric (also listed on the home page).
The Java-style guidebook is located here.
Your final grades are calculated using the Grading Policy
If you do follow an alternative style guide, please provide them to the moderator and TAs and demonstrate that you are following this certain convention
reflecting a certain section of the guidebook listed above.
This implementation is to maintain grading standards across sections.
We will bias clarity over cleverness in evaluating your code. You should adopt a “teaching” mindset, always asking yourself, “How would I change
what I have written to make it as easy as possible for someone else to understand my code without my direct assistance?”
Category Scoring Notes
Basic Preparation 2 2 pts – Comes to the section on time within 10 minutes and fully setup
Questions that appear in lecture quizzes may come from the assigned reading, so it is in your best interest to complete it.
Basic
Requirements
(25)
Presentation 3 -1 pt: Student’s presentation exceed the allotted time
-1 pt: Student’s presentation does not present the functionalities implemented that week
-1 pt: Student’s presentation does not highlight how styling was taken into account while coding, how
improvements were made from previous weeks in styling or did not show how current week’s rubric for styling
was taken into account
-1 pt: Student’s presentation does not include what they think they had not done well and wants to improve
Participation 3 +1 pt for each interaction: Interact with the group 3 times (ask a question, make a comment, help answer a
question, etc.)
Effort 2 -1 pt: The effort on complying with best coding practices.
-1 pt: The effort on completing functional requirements.
Commenting
/Documentation
3 -1 pt for each infraction:
Block comments should be written for all public functions and nontrivial private functions with clear
documentation.
Inline comments should be written to provide context to a non-intuitive solution
Code submission 4 -1: Repo URL correct
-1: Repo named correctly
Submit code with multiple commits:
-2pt with only one commit message
-1pt for multiple bad commit messages
-1pt for committing the Doxygen files
+0.1pt for very exceptional commit messages
Decomposition
/Overall Design
4 -1 pt per infraction:
Any piece of the project must execute its core functionality well.
The project should be well decomposed into classes and methods.
The project is adequately decomposed into abstract classes and classes. The abstract classes and
methods with shared functionality from different parts should generalized and reusable.
Functions are not duplicated and you make an effort to ensure that duplicate pieces of code are refactored
into methods.
The project should be maintainable, which means it should be easy to make changes to parts of the project
without breaking its functionality. Tests should also be up to date.
(Slightly hard) The code should be readable. (If moderators need to re-read the line twice to understand
what it does, it is not readable.)
Style guide 4 -1 pt per infraction: follow Java styling conventions until section 4; For all styling conventions, please refer to this
doc.
Functional
Requirments
(16 pts)
Custom Chess
Pieces
5
+ 2 points for each custom chess pieces. They are a simple combination of two standard chess pieces.
Any piece which is in this link would constitute 2 points.
+0.5 points added to the 2 points above for each custom chess pieces that are unique (not in this link) and
the algorithm used to describe its movement is complex and different from the movements of standard
chess pieces.
Static User
Interface
5
4 points – The UI consists of a neat layout that accurately represents a chessboard. The UI consists of
symbols/pictures for each of the chess pieces.
5 points – The UI is extremely appealing and shows that the student has put in considerable effort into the
design of the layout. The UI consists of commands/clickable buttons for each tile and basic interactions are
enabled in the UI.
+2 points bonus for implementing GUI instead of terminal UI.
Doxygen
Generation
3
0 points – No Doxygen file
1.5 points – Generate a partially complete Doxygen file
3 points – Generate and demonstrated a complete Doxygen file
+0.5 points added if the Doxygen is of high quality
Refactoring
/Completing
missing functions
3
1 point – The code still contains a lot of duplicate/redundant code with room for a lot of improvements. OR
The code still lacks functionality from last week
2 points – There is not much duplicate/redundant code and the student has put effort to refactor code from
last week. AND The code also contains all requirements from the previous week. However, there is still
room for improvement.
3 points – Every piece of code is functional and the overall design of the project is so well designed that it ca
nnot be refactored/improved any further.
Testing (9 pts) Testing 5 Unit tests are written for all new code & expanded last week’s tests if necessary
0 pts when JUnit tests have coverage below 30%
1 pts when JUnit tests have coverage above 40%
2 pts when JUnit tests have coverage above 50%
3 pts when JUnit tests have coverage above 70%
4 pts when JUnit tests have coverage above 80%
5 pts when code coverage is 95% or more.
Manual Test Plan 4
0 pts if there are no manual test plan
1 pts if the test plans include only environment setup OR scenario descriptions
3 pts for test plans that contained most of the content but can be further improved (~8 pages)
4 pts for well-composed test plans (~12 pages)
Full Score 53


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论