Write a program that simulates the operation of a halloween

Assignment Help Computer Engineering
Reference no: EM131965150

Assignment

Write a program that simulates the operation of a Halloween Vampire Hunt game.

In the game scenario, you are a vampire hunting a victim in a dark cave. The cave consists of 10 by 10 little squares, numbered 0-9 on each side; your victim is in the cave, with x-coordinate and y-coordinate 0-9 (both integers). On each turn, you guess where your victim is, and try to bite her/him.

Your "health" is determined by the number of bloodpoints you have. At the beginning, your bloodpoints are initialized to a random integer, evenly distributed from 5 to 10, inclusive.

Unfortunately, there are also vampire hunters in the cave, shooting arrows at you. (The arrows are wood, of course, for killing vampires.) On each turn, generate a random integer from 0 to 2, inclusive.

If the random integer is 0, an arrow misses you; no damage is done
If the random integer is 1, an arrow grazes you; you lose one bloodpoint
If the random integer is 2, an arrow hits you; you lose two bloodpoints

The game ends when 1) you guess where your victim is and bite her/him, or 2) you are shot by too many arrows, and your bloodpoints drop to zero or below.

Your program performs these operations:

1) generate random x and y coordinates for the victim (both integers, 0-9) (use the myRand() method, defined below)
2) ask if the user would like to cheat
3) if the user is cheating, print the location of the victim
4) generate initial random bloodpoints for the vampire (5 to 10, an integer) (use the myRand() method, again)
5) prompt the user to enter x and y coordinates (guess where victim is)
6) display the distance between the vampire and victim (use the findDistance() method, defined below)
7) check whether an arrow hits/misses the vampire; update bloodpoints (use the myRand() method again) repeat (5) - (7) until the vampire guesses the correct location of the victim, or the vampire's bloodpoints drop to zero or below

Your program should produce identical output to the sample executable, when compiled and run on libra. (Obviously some parts of the output will be different, because of the random numbers!) Sample runs:

libra% java Vampire
Welcome to the vampire hunt game!
Would you like to cheat? (1 for yes, 0 for no): 0
You start with 5 blood points.

Enter your target x and y-coordinates (both 0-9): 0 2
You are 4.00 units from your victim.
You were grazed by an arrow, oops.
You have 4 blood points.

Enter your target x and y-coordinates (both 0-9): 1 2
You are 4.12 units from your victim.
You were hit by an arrow, ouch.
You have 2 blood points.

Enter your target x and y-coordinates (both 0-9): 1 1
You are 5.10 units from your victim.
You were grazed by an arrow, oops.
You have 1 blood points.

Enter your target x and y-coordinates (both 0-9): 4 4
You are 4.47 units from your victim.
You have 1 blood points.

Enter your target x and y-coordinates (both 0-9): 4 9
You are 5.00 units from your victim.
You were grazed by an arrow, oops.
Sorry, you were shot too many times; game over
libra% java Vampire
Welcome to the vampire hunt game!
Would you like to cheat? (1 for yes, 0 for no): 1
Victim at 7 6
You start with 10 blood points.

Enter your target x and y-coordinates (both 0-9): 7 4
You are 2.00 units from your victim.
You have 10 blood points.

Enter your target x and y-coordinates (both 0-9): 7 5
You are 1.00 units from your victim.
You were hit by an arrow, ouch.
You have 8 blood points.

Enter your target x and y-coordinates (both 0-9): 7 7
You are 1.00 units from your victim.
You were grazed by an arrow, oops.
You have 7 blood points.

Enter your target x and y-coordinates (both 0-9): 7 6
You are 0.00 units from your victim.
You bit your victim! S/he is now a vampire.
libra%

You must organize your program so that your main program calls two methods. The first one is myRand():

int myRand(int low, int high)

myRand() returns a random integer from low to high (inclusive), with equal likelihood.

The second method is findDistance():

double findDistance(int x1, int y1, int x2, int y2)

findDistance() returns the distance between the two points (x1, y1) and (x2, y2). This is defined as

√( (x1 - x2)2 + (y1 - y2)2)

Programming style and documentation: You must follow the programming style and documentation guidelines for previous projects. In addition, each method should have a method header, including the definition and a brief description of what the method does. For example, for iPow():

/********************************************

int iPow(int x, int y)

returns x to the power y
y must be a non-negative integer

********************************************/

Reference no: EM131965150

Questions Cloud

Long-term relationships with key supply chain participants : Developing long-term relationships with key supply chain participants (e.g., consumers, intermediate customers, and suppliers) can be best described as:
Most common difficult to manage challenges : Identify two of the most common difficult to manage challenges in projects and suggest how effective project management can address them.
Discussions about electronic health : Why would it be important to introduce the clinicians to standardized terminologies and involve them in discussions about electronic health records.
What is the movie trying to say : What is the movie trying to say? How does this relate to class material? Does the movie support or refute what sociology has to say about a social issue?
Write a program that simulates the operation of a halloween : Write a program that simulates the operation of a Halloween Vampire Hunt game. In the game scenario, you are a vampire hunting a victim in a dark cave.
What is the discounted payback : If the cash flows are expected to be $15,000 over the next five years. If the discount rate is 8% what is the discounted payback? (round to the hundredth)
Describe the three types of franchising : Describe the three types of franchising and give an example of each.
What is the monthly payment on both offers : A customer is looking to purchase a furniture set with three end tables for $2500. The customer has the option of (a) 12-month special financing with a 20%.
Describe any personal challenges you faced in adulthood : Describe any personal challenges you faced in adulthood, and explain how they affected your family.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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