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

  Investigate the characteristics of grid computing

Study the PCI and USB bus architectures. What support do they provide for configuring multiprocessor systems?

  What is a credit-balance function and how is it used

What is a credit-balance function, and how is it used? In the big-O notation, what is the cost of splaying amortized over sequence of retrievals and insertions?

  Program showing duplicate values in an array

Write down a program in C in order to show the duplicate values in an array, Documentation and Naming Style Sheet should include: Description of what program does, Summary of the problem's specifications and assumptions.

  Identify two it related projects that would be consistent

Identify two IT - related projects that would be consistent with this plan. Recommend one of the two projects for implementation.

  What is the difference between a breakpoint and a watchpoint

gdb refuses to run a program or list its source. What could be the possible reason? What is the difference between a breakpoint and a watchpoint?

  Create function named reduce that takes two positive integer

Create a function named reduce that takes two positive integer arguments, call them num and denom, treats them as the numerator and denominator of a fraction.

  Can you provide some insight and information

Can you provide some insight and information as to how this can help me be more productive? Do you know what might be causing this or what I should check?

  Explain how you would build your work breakdown structure

If you were managing an agile development project, explain how you would build your work breakdown structure (WBS). Explain the di erences between unit testing and system testing.

  Questioncs 136 systems analysis and design -course project

questioncs 136 systems analysis and design -course project -you have to complete and submit course project previous to

  Create a work breakdown structure code for each given task

Create a Work Breakdown Structure Code for each task. Determine an overall project duration and duration estimates for each of the tasks. The duration is not to exceed 90 days.

  How you would handle the event for each of the b-tree

Suppose that one page from the database is destroyed. Describe how you would handle this event for each of the B-tree structures described in the text.

  Write the code to convert a jcombobox named mycombo

Write the code to convert a JComboBox named myCombo into one that will accept user input as well as display a drop-down list.

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