ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 28 Apr 2017 My Price 11.00

JAVA PROGRAMMING

JAVA PROGRAMMING

Attached is the pdf of the assignment. Please follow all the guidelines and instructions. Make sure your source code does compile and run perfectly. There are sample output in the pdf you can use to test your source code.  Make sure your source code is internally documented and you complete the top-down design diagram as outlined in the pdf submission section; otherwise I won't accept the answer. Thanks

 

 

Assignment 7: MARK Game CPSC 1150-005/006, Spring 2017
Instructor: A. Goldberg
Langara College Introduction
You will design and implement a modular program called MarkGame that allows a user to play the
game MARK against the computer.
Note that the implementation of this program should not take more than a few
hours once you have planned properly. Do NOT start coding until you have fully
analysed the problem and used top-down design methodology to create a solution. Preparation
You are expected to be familiar with the following textbook sections and lectures, and to complete
the following exercises before attempting the assignment. You may work with a partner for this
assignment. Textbook sections
• Chapter 6 (especially 6.11) Most relevant lectures
• L11, L12, and especially L13 Exercises
Note: Your final top-down design diagram must be handed in.
1. You guessed it: Read through the lab!
2. Play a small game of MARK against a friend/classmate, starting from the number 12.
3. (You will need to do this on a computer, or scan your diagram to hand in.) Draw a top-down
design diagram for the MarkGame program. Start with the whole problem at the top, and
break it into subproblems, then break each of those into subproblems, etc. Your bottom level
subproblems should be simple enough that you can easily figure out how to implement them.
Before beginning to code, make sure the lowest-level subproblems in your diagram are extremely simple (just a few lines of code, performing exactly one task). Also make sure your
design addresses all of the specifications.
This will be your first draft of the diagram, but once you’ve begun to implement the program,
you may need to return to and adjust your diagram. 1 Assignment 7: MARK Game CPSC 1150-005/006, Spring 2017
Instructor: A. Goldberg
Langara College The rules of MARK
MARK is a game1 played by changing a non-negative integer, using certain legal moves, until no
more legal moves remain. The first player who cannot make a move loses the game.
In the MarkGame program, the user should play MARK against the computer. The current
position is represented by a non-negative integer. The game starts with a random integer from 1
to 100 being generated as the starting position. Then, the user and the computer alternate taking
turns modifying the current position.
A turn consists of modifying the current position in one of two ways:
1. Subtract 1 from the current position.
2. Divide the current position by 2 (and round down).
The game ends when the position is 0. If the current position is 0, the next player to take a
turn loses. That is to say, the player who moved last wins. Specifications
Some sample output is included at the end of this document.
Beginning of the game: Display the game title and some brief instructions for playing the
game. Ask for the player’s name. The starting position should be a random integer from 1
to 100.
Beginning of each turn: Display the current position, and indicate whose turn it is. User’s turn: The user should be prompted to either subtract 1 or divide by 2. The user may
indicate their choice however you like. Your program should handle invalid user input.
Computer’s turn:
each time. The computer should randomly decide which of the two legal moves to make End of game: The game ends when the position is 0, and the current player (next to take a
turn) loses. When the game ends, the program should indicate which player won.
Javadoc: You must use javadoc comments for each method and for your class. You should
try running javadoc on your source code before submitting, just to see that you’ve done it
properly. Do not submit the html files. When your assignment is marked, the javadoc will be
generated directly from your source code. The top-down design process
The program must be designed in a modular way, and must match the top-down design diagram
that you submit. When you implement your methods, you have two options. Pick one of the
following options, and stick to it all the way through.
1 The game MARK was first proposed by Aviezri Fraenkel, and is a topic of study in Combinatorial Game Theory. 2 Assignment 7: MARK Game CPSC 1150-005/006, Spring 2017
Instructor: A. Goldberg
Langara College (1) Top-down implementation: Start implementing methods from the top of the diagram,
moving downwards, and repeat the following steps for each method:
1. Fully implement the current method.
2. Write a stub (a temporary method that only has a return statement, allowing you to
verify whether it has been called) for each method that the current method calls.
3. Test the current method until it is working properly.
For example, if met1 calls met2 and met3, implement met1 in full. Write stubs for met2
and met3. Then test met1 until it’s working properly. After that, you may move on to
implementing met2, using the same strategy.
(2) Bottom-up implementation: Start implementing methods from the bottom of the diagram, completing each lower level of methods before moving upwards, and repeat the following
steps for each method:
1. Fully implement the method.
2. Write some code in main to test the method until it is working properly.
3. Erase that code from main.
If using this option, you cannot implement a method on an upper level until all of the methods
it calls have been implemented. Submission
Recall that submission instructions are in the Assignment Guide. You are required to submit
one .zip folder to D2L containing:
• the internally documented (Javadoc!) and properly styled source code file: MarkGame.java
• your top-down design diagram
The file should contain your name in the header. Make sure to save a copy of the finished code to
your personal H: drive. 3 Assignment 7: MARK Game CPSC 1150-005/006, Spring 2017
Instructor: A. Goldberg
Langara College Sample output
Display at startup
__
|\ /|
/\
| \ | /
| \/ | /__\ |__/ |<
|
| /
\ | \ | \
Welcome to MARK!
You are playing against a computer opponent.
On your turn, you must modify the current game position.
You may either subtract 1 by typing - or divide in half by typing /.
The game position must always be a non-negative integer.
The game ends when the position is 0, and the current player loses.
Your goal is to make the last move that brings the position to 0.
Please enter your name: Adina Sample game play
Adina’s turn. Position is: 9
Please enter - or /: Computer’s turn. Position is: 8
Computer chose to subtract 1.
Adina’s turn. Position is: 7
Please enter - or /: /
Computer’s turn. Position is: 3
Computer chose to divide by 2.
Adina’s turn. Position is: 1
Please enter - or /: Computer’s turn. Position is: 0
No legal moves remaining.
Congratulations, Adina! You win! 4

Attachments:

Answers

(11)
Status NEW Posted 28 Apr 2017 03:04 AM My Price 11.00

-----------

Not Rated(0)