create a version of a carnival game

Assignment Help Basic Computer Science
Reference no: EM13161397

your job is to create a version of a carnival game in which mechanical dogs race along a track. The racing game is called DogTrack. DogTrack is also the name of the java source file you must submit to complete the assignment. The DogTrack class should be written so that the driver class below, DogDriver, works as intended.


A dog track has N discrete positions, 0 through N-1. The value of N is determined interactively in the application driver (below) once your program begins running.

There are three dogs, named Fido, Spot, and Rover. Each starts at position 0. A spinner selects (returns) a random value from among the values 1-2-3-4-5; these values are equally likely. Each dog advances by a separate spin of the spinner. In general a dog advances 1 space when the spinner spins a 1, 2 spaces when the spinner spins a 2, and so forth. The game is over when (at least) one of the dog crosses the finish line, that is, when at least one dog reaches a board value that is greater than or equal to (N-1).

A special condition: if a dog lands exactly at position number N/3 or position number 2N/3, where N is the size of the track, then that dog returns to its position before the move was made, and then moves back one more square, if possible. Because there are no negative positions, a dog at 0 that advances to N/3 on the first move does NOT go to (negative) position -1; after the move it should simply remain at position 0. See sample run below for an example.

At each round, the track should be drawn, using the symbol o, and the letters F, S, and R (for Fido, Spot, and Rover).

You should draw the state of the race as three "lines", one for each dog, using an 'o' to represent unoccupied positions, and F,R, and S to represent dog positions. These 3 line groups should be separated by a row of dashes, as shown in the sample run below. If the track size is 10, then this drawing

ooooooSooo


means that the dog Spot is at location 6 on the track, with earlier positions 0-5 unoccupied (dog tracks always begin with position 0).


Here is the driver class for the racing game:

import java.util.Scanner;   
public class DogDriver{       
  public static void main(String[] args){      
    System.out.println("Enter an int > 3: size of the track");     
    Scanner s = new Scanner(System.in);      
    int trackSize = s.nextInt();      
    System.out.println("track Size: " + trackSize);      
    DogTrack d = new DogTrack(trackSize);      
    d.playGame();    
  } 
}   


Here is a sample run:

 
> run DogDriver
Enter an int > 3: size of the track

----------------------------

8

----------------------------

track Size: 8 // so positions are 0,1,...,7; position N/3 = 8/3 = 2 is a go-back square, as is position (2*8)/3 = 5.

Fooooooo // all dogs start a position 0

Sooooooo

Rooooooo

--------

ooooFooo // at position 4

oooSoooo // at position 3

Rooooooo // Rover spins 2, but 8/3 = 2, so Rover goes back to 0, but NOT to position -1

--------

oooFoooo // Fido, at position 4, spins a 1, to location 5 = (2*8)/3, so: back to original position 4, then back 1, to pos 3

ooooSooo

ooooRooo

--------

ooooFooo

oooooooS // S & R have reached position 7 = tracksize - 1, terminating the game

oooooooR

--------

Spot Wins!

Rover Wins!

A requirement: your DogTrack class must include and MAKE ESSENTIAL USE OF the following methods, in addition to the DogTrack constructor and principal method playGame(). These are:

  * spin - generates an integer value from 1 to 5 at random

    * move - advances the pieces (alternative:  instead of a move method write 3 separate methods, moveRover, moveSpot, moveFido)

    * isOver - checks if race termination condition has been met

    * showTrack - draws the three tracks using 'o' and a dog letter to indicate dog position. Should insert a row of dashes after the three tracks are displayed.

    * showWinners - reports the winning dog or dogs when the race ends (see example above.)

Suggestions on how to proceed (only suggestions though):

* idea #1: get your code running but ignore the N/3 + 2N/3 stuff. You can add that in later. Also, don't worry at first about drawing the board correctly. Just print out the values of the dog positions.

* idea#2: Before you write any of the required methods explicitly, write the playGame method using the named methods above as if they already existed. Be sure to think about and account for any parameters each method might have.

What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture? 

Reference no: EM13161397

Questions Cloud

Define u.s. plans new strategy for hiv : The Obama administration plans to unveil a new AIDS strategy Tuesday, aimed at reducing new infections and increasing the number of HIV-positive people getting care.
Explain orbital and an unpaired oxygen electron : The figure-8 bond orbitals around the carbon and oxygen atoms actually extend to infinity but do have two overlapping areas. C)This bond is the result of the interaction of an unpaired carbon electron in the 2s orbital and an unpaired oxygen elect..
What is the frequency of males hemizygous for the d allele : A) If the f(D) of an X-linked gene in a population = 0.8, what is the f(d) of the other allele at this locus?
interlocking words on a Scrabble board : The board game Scrabble works by assigning points to wooden tiles that are marked with printed letters, and are arranged as interlocking words on a Scrabble board.
create a version of a carnival game : assignment, your job is to create a version of a carnival game in which mechanical dogs race along a track. The racing game is called DogTrack. DogTrack is also the name of the java source file you must submit to complete the assignment. The DogTrack..
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?
What are the benefits of using tangible interfaces : What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?
Write a program to print duplicates in a string and count : 1. write a program to print duplicates in a string and their count.

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  Good meetings in software development life cycle

Provide three words or phrases that explain why "good meetings" are important during the Software Development Life Cycle?

  Determine companies which specialize in computer forensics

What needs clarified? it's plainly stated use google to find 3 companies which specialize in computer forensics of those 3 companies write 2 or 3 paragraphs comparing what each company does.

  Explain reads and writes using lipner-s matrix

Who in Lipner's model can make this change? Explain the reads and writes necessary to make this change and justify the read and write using Lipner's matrix.

  Difference between data block-extent-segment and tablespace

Allocation in Oracle can aid recognize problems more easily. In your own words, give the description of difference between data block, extent, a segment, and a tablespace.

  What is the primary role of chief information officer

What is the primary role of the Chief Information Officer in organizations today? If you are able, please use your own organization in your response.

  Study evidence for defence in law firm

You are engaged by law firm to study evidence for the defence. You uncover evidence that doesn't help your client's case but was not discovered by the prosecution.

  Explain use of gross domestic product-measure business cycle

Explain the use of Gross Domestic Product (GDP) to measure business cycle. Explain the roles of government bodies which determine national fiscal policies.

  Difference and similarity between matlab and vba syntax

1. What's one difference you've noticed between MATLAB and VBA syntax? What is one similarity?

  Communication links on the telephone network

The time delay of a long-distance call can be determined by multiplying a small fixed constant by the number of communication links on the telephone network between the caller and callee. Suppose the telephone network of a company named RT&T is a fre..

  Explain make-buy decision for management prerogative

Make-buy decision is the significant management prerogative. You are manager of software organization which has average software development cost of $20.00/LOC.

  Implement a system for car dealership

Suppose that you are required to implement a system for a car dealership. The system needs to store information about each customer. This includes the customer's ID number, name, address and contact number.

  Full-duplex trunk between end office-intermediate switch

In a simple telephone network comprising of two end offices and one intermediate switch with 1-MHZ full-duplex trunk between each end office and intermediate switch.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd