fictitious game

Page 1 of 1

5 Replies - 372 Views - Last Post: 21 June 2010 - 09:16 PM Rate Topic: -----

#1 Guest_elizabeth*


Reputation:

fictitious game

Posted 21 June 2010 - 10:50 AM

The code you are to write is to complete an implementation of the game "Race for Breakfast". This is a
ficticious game!
Beware: the version that you implement must match the specifications given below and use the
resources provided (even if you prefer some other variant of the game). Other implementations will
score poorly.
In this game the user is in a system of interconnected streets driving around trying to find breakfast. Each
street is connected to three other streets. Breakfast can be purchased for $2 from a fast-food restaurant
located in one of the streets. But the restaurant is at least five minutes' drive away from the user's initial
position, and breakfast is only served for an additional four minutes. So, the user is going to have to break
the law in order to make it to the restaurant before it stops serving breakfast.
If the user drives into the street containing the restaurant they will crash; the aim is to locate the street
containing the restaurant and purchase breakfast. The user starts with $6 and may spend this in $2
amounts in any street. If they spend it in a street other than that containing the restaurant then they lose
their $2 and get nothing in return. To make the task a little more challenging, the police are located in one
street looking for speeding vehicles, if the user enters this street they will get arrested!
It is possible for the user to have some idea of the location of the restaurant because its unique smell wafts
into connecting streets.
It is also possible for the user to have some idea of the location of the police because the noise of their
blaring siren can be heard in connecting streets.
This is a sample output of a stage 2 implementation of this game.
The completed implementation will consist of 3 files, only one of which must be written by you. These
files are:
AssigTwo.java This is the driver program (with a main() method). The code of this is
complete and it MUST NOT be changed. The code in this file is very simple - it declares and
instantiates an object of the RaceForBreakfast class. (The on-line version of this document has
a link to the code.)
MBot.java This file contains resources that you are to use in developing your implementation of
the game. The code is complete and MUST NOT be changed. (The on-line version of this document
has a link to the code.)
RaceForBreakfast.java This is the file that you are to write, the on-line version of this
document has a link to a "skeleton" version of the code - use this as the starting point for your
program.
There will be no main() method in the class, it will contain methods that organise the game.
This will include all the interactions with the user.
You should make sure that you do the following:
Create and use object(s) of the MBot class. You will LOSE MARKS if you write code
in RaceForBreakfast.java that duplicates things that could be done using
methods of the MBot class.
Use the trace() method (provided in the skeleton) to include tracing messages in
your program - switch the messages off before submission.
Use separate methods to implement the separate tasks within the game.
Use instance variables to store data that is used or changed by more than one method.
Use local variables to store the data that is used by just one method.
This program (like all programs) should be developed in stages, with each stage fully implemented and
KXQ101 Semester 1, 2010 Assignment 2 file:///C:/Documents%20and%20Settings/jdscanla/Desktop/Assignmen...
2 of 9 18/05/2010 5:40 PM
tested before the next stage is attempted. To provide you with some GUIdance about this, the detailed
specification below is divided into four stages.
A program that correctly implements stage 1 and provides all the required external documentation, both to
a high standard will be able to score a maximum of 48 of the 60 marks. This is 80% - a high distinction. If
you have done all of this in plenty of time and want to try for an even higher mark, then you should begin
to implement stage 2, and if you have time, stages 3 and 4.
VERY IMPORTANT: You must state in the header comments of your source code which stage of
implementation your program has reached. If you do not do this, then the marker will assume that you
have only implemented stage 1 and you will not receive any marks for implementation of any other stages.
Details - Stage 1
(Note: even within stage 1, you should plan, implement, and test you program in sub-stages. It
is part of your task to work these sub-stages out yourself.)
Write code in RaceForBreakfast.java to do the following:
"Housekeeping" tasks
Switch off the tracing messages in MBot objects and the RaceForBreakfast
class.
Whenever an MBot object is created make a call to its setUp() method with
the parameter value 0.
Introduction
Provide the user with a general description of the game.
Play the game - the user is prompted to make "moves" until the game is over.
The game will end when any one of the following happens:
The user buys breakfast (user wins).
The user crashes into the restaurant (user loses).
The user is arrested by the police (user loses).
The user chooses to quit the game (user loses).
Before each move the user is provided with the following information:
Their location (street number) in the street system.
The numbers of the three connecting streets.
The amount of money they have.
Any available information about the location of the restaurant or the
police:
If the restaurant is in a connecting street there will be a horrible
smell.
If the police is in a connecting street there will be the sound of their
siren.
The user is asked what they want to do for this move. The options are:
Drive into another street.
They will be asked to enter the number of the street they want to
drive into.
If this is not connected to their current location they will not
be able to drive, and should be told they need a map.
If this is connected to their current street, they will enter the
new street (that is, their location will change to the chosen
street); if this is the street with the restaurant, they will crash;
if this is the street with the police, they will be arrested; if this
street is empty; this street will be their new location and the
game will continue, they will be provided with information
and prompted for their next move.
KXQ101 Semester 1, 2010 Assignment 2 file:///C:/Documents%20and%20Settings/jdscanla/Desktop/Assignmen...
3 of 9 18/05/2010 5:40 PM
Purchase breakfast from another street.
If they have any money, they will be asked to enter the number of
the street they want to purchase breakfast from, otherwise they will
told that they cannot buy breakfast and be prompted for their next
move.
If the street they choose to purchase breakfast from is not connected
to their current location, their money will be lost.
If the street they choose to purchase breakfast from is connected to
their current location and is the street that contains the restaurant,
then breakfast will be purchased and eaten; if it is connected but
does not contain the restaurant, the money will be lost in the empty
street, and the user will be prompted for their next move.
Quit the game.
The game will end.


AM HAVING A DIFFICULTY IN UNDERSTANDING HOW TO IMPLEMENT THE PROBLEM.
CAN U GIVE ME HINTS HOW TO START.

Is This A Good Question/Topic? 0

Replies To: fictitious game

#2 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: fictitious game

Posted 21 June 2010 - 10:55 AM

Might try giving a bit shorter summary of your problem. No one will read through all of that I'm sorry to say.
Was This Post Helpful? 1
  • +
  • -

#3 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: fictitious game

Posted 21 June 2010 - 12:02 PM

I agree with eZACKe. A person has a limited attention span. If you cant sum it up with a sentence or 2 we will loose interest. Break the program into sections is the best part to do. What do you need to implement first, second, and so forth... After you post a fixed summary and break it down (or want us to help break it down to a more manageable form) then we can work from there.

Im more then willing to help you though. :)
Was This Post Helpful? 0
  • +
  • -

#4 Ember  Icon User is offline

  • D.I.C Head

Reputation: 70
  • View blog
  • Posts: 160
  • Joined: 24-April 10

Re: fictitious game

Posted 21 June 2010 - 01:04 PM

From the flow diagram of this game, it sounds pretty simple to implement if you understand these horribly written instructions.

So this is what is going on. Say you start on street "1". The restaurant is on street 4 and the police are on street 5. The street diagram looks like this in terms of connecting streets:
1--2--5
|
3--6--4

So you start on street 1 and are given the option to go to either 2 or 3. If you go to 2, the program should pop with a box saying "You hear sirens in the distance" which means that the sirens are in an adjacent street. If you are on 2, your choices for streets are 1 and 5. If you choose 5, you lose. Throughout this entire game, you should have the option to "purchase a meal" from any street number. If the street is not adjacent, you automatically lose the money. If it is adjacent, but it isn't the restaurant, you automatically lose the money. If it is adjacent and you choose the right street, you win.

So in the example, you can only win if you are on street 6 and choose street 4 to buy from. You lose if you actually drive to 4 because...that is the way the game works.

To implement we would have to see the classes he provided since I don't know what he has already implemented. It says that you can't copy any of the implemented stuff he has in mbox, so we have to see mbox or you lose points.
Was This Post Helpful? 2
  • +
  • -

#5 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10444
  • View blog
  • Posts: 38,682
  • Joined: 27-December 08

Re: fictitious game

Posted 21 June 2010 - 05:47 PM

If you are familiar with Graph Theory, then I would highly encourage you to explore this avenue, as it could be a very elegant solution.

Is there a specific question you have or a concept you are unsure about? Just asking for pointers for such a large question doesn't give us an idea of how to help you. Can you narrow it down some?
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: fictitious game

Posted 21 June 2010 - 09:16 PM

I tough all games where fictitious :)

Anyhow the display the official forum rule introduced by macosxnerd101

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1