Description For this part of the assignment, you will create a Grid representing the pacman’s game grid by using a 2D array of Strings as shown in Section 1. Also, you will design the functionality of the pacman as described in Section 2 and represent it in the grid. 1 The Grid The dimensions of the grid is 15 x 15 and the gird is composed of 4 boundaries: north, south, east, and west boundaries as shown in the Figure. The grid has the following characteristics: 1. The boundaries are represented with “X”, and this will block the pacman. 2. There may be obstacles that obstruct the pacman’s movement. 3. There are 4 gates represented with “ ”, and these gates communicates with the opposite gate. E.g., the north gate communicates with the south gate, and the east gate communicates with the west. This means that if the pacman is located in the north gate, next time it moves up will appear in the south gate, similar with the east and west gate. 4. The grid contains cookies represented with “.”. The idea is to collect all the cookies from the grid in order to win the game. Every time the the pacman eats a cookie, the cookie disappears. The Grid has the following fields • grid: is a 2D array of Strings • x-pos: the x-coordinate where the pacman is located • y-pos: the y-coordinate where the pacman is located • counter: a counter that represents the total number of cookies consumed by the pacman In addition, the Grid has the following methods: • initializeGrid(): This method will print a “fresh” new grid with the pacman located in the middle of the grid and the rest of the grid will contain cookies “.”. Except the boundaries of the grid. Your maze shall have four boundaries i.e., north, south, east, and west. The boundaries are represented with an “X”. Each boundary has a gate in the middle that allows the pacman to communicate to the opposite gate. • updateGrid(): will happen after the selection of moving “a”,“s”,“d” or “w” is done. Since these four options will move to west, south, east, or north, then you need to “update” the grid. The way to do this is by passing the x-coordinate and the y-coordinate as arguments to this method. The method then, will update the new position of the pacman (that is, the x and y coordinate from the arguments). Here is where the previous x and y position of the pacman will “disappear” (which is now a blank space “ ”). This method will reflect the new position of the pacman in the grid in case it moved. This method will also reflect the number of cookies consumed. • checkBoundaries(): Before moving the pacman to the new position, this method will check if is possible according the current coordinates. In case is a valid movement, the method will return true. In case the movement is invalid, due to a boundary or through something else, then your method will return false. The Pacman The pacman has the following characteristics: • The pacman has the ability to move through the gates (i.e., north to south, east to west). • The maze is full of cookies (e.g., “.”). The pacman must eat all the cookies to finish the game. Every time the pacman eats a cookie, it disappears from the maze the counter increases by 1. • If pacman movesUp by typing the key w, the pacman’s y-coordinate must increase by one unit. If the pacman’s y-coordinate exceeds the maze’s upper boundary, then the pacman’s y-coordinate AND the maze’s position shall not be updated. • If pacman movesDown by typing the key s, the pacman’s y-coordinate must decrease by one unit. If the pacman’s y-coordinate exceeds the maze’s lower boundary, then the pacman’s y-coordinate AND the maze’s position shall not be updated. • If pacman movesRight, by typing the key d, the pacman’s x-coordinate must increase by one unit. If the pacman’s x-coordinate exceeds the maze’s right boundary, then the pacman’s x-coordinate AND the maze’s position shall not be updated. • If pacman movesLeft, by typing the key a, the pacman’s x-coordinate must decrease by one unit. If the pacman’s x-coordinate exceeds the maze’s left boundary, then the pacman’s x-coordinate AND the maze’s position shall not be updated. Notice that by moving through the y-coordinate the program deals with the rows of the array, similar when dealing with the x-coordinate, the program deals with the columns of array. 3 The Game Engine In order to simulate a game, you must have an engine that keeps looping the position. This is exactly what happens in the old movie theater when they have the 35mm projectors. Here, we will simulate the same idea with a loop: 1. import java.util.Scanner; 2. public class Engine{ 3. public static void main(String [] args){ 4. String[][] grid = new String[10][10]; 5. int col = 5; 6. initializeGrid(grid); 7. grid[5][col] = "P"; 8. Scanner input = new Scanner(System.in); 9. while(true){ 10. print(grid); 11. String option = input.nextLine(); 12. if(option.equals("d")){ 13. // code goes here 14. } 15. // more code goes here 16. } 17. } 18. // methods go here 19. } In Line 4, will create a grid of 10 x 10 of Strings. In Line 7 will store the pacman (’P’) in the middle of the maze. In Line 9 will allow to run your program “forever” until you decide to finish your program. Line 11 will wait for the input from the user to move the pacman (i.e., “a”, “s”, “d”, or “w”). A complete engine can be found in Grid.java.
In: Computer Science
How does the RDBMS support Business Intelligence Applications?
In: Computer Science
Part 2:
i = 2.1(1-e-9t)
You have been asked to determine the time taken for the current to rise from 1 to 1.5 amps.
Comment on the time taken for the current to rise the same increment from 1.5 to 2 amps and give reasons. You are not required to evaluate this.
You have been asked to determine the length of the belt, using trigonometric techniques, assuming the belt is in tension.
In: Math
I have been given a final year project to develop a model for ‘Spare part inventory control and management’ for multinational company. the model should include the best suitable classification method and a simple mathematical approach for forecasts. Suggest me the best approach to accomplish this. I am expecting,
Help me to develop the model with a limited time frame due to heavy workload. Thanks
In: Operations Management
Consider a plane wave of monochromatic green light, ? = 500 nm,
that is incident normally upon two identical narrow slits (the
widths of the individual slits are much less than ?). The slits are
separated by a distance d = 30 µm. An interference pattern is
observed on a screen located a distance L away from the slits. On
the screen, the location nearest the central maximum where the
intensity is zero (i.e., the first dark fringe) is found to be 1.5
cm from this central point. Let this particular position on the
screen be referred to as P1.
(a) Calculate the distance, L, to the screen. Show all work.
(b) calculate the ditance between the first and second dark bands in the interference pattern. Shown all work.
(c)In each of the parts below, one change has been made to the
problem above (in each case, all parameters not explicitly
mentioned have the value or characteristics stated above). For each
case, explain briefly whether the light intensity at location P1
would remain zero or not. If not, will P1 become the location of a
maximum constructive interference (bright) fringe? In each case,
explain your reasoning.
1) One of the two slits is made slightly narrower, so that the
amount of light passing through it is less than that through the
other.
2) The wavelength is doubled so that ? = 1000 nm.
3) The two slits are replaced by a single slit whose width is
exactly 60 µm.
In: Physics
1.On a spacecraft, two engines are turned on for 542 s at a
moment when the velocity of the craft has x and y
components of v0x = 2960 m/s and
v0y = 5010 m/s. While the engines are firing,
the craft undergoes a displacement that has components of
x = 3.31 x 106 m and y = 4.76 x
106 m. Find the (a) x and
(b) y components of the craft's
acceleration.
2.A horizontal rifle is fired at a bull's-eye. The muzzle speed of the bullet is 690 m/s. The gun is pointed directly at the center of the bull's-eye, but the bullet strikes the target 0.028 m below the center. What is the horizontal distance between the end of the rifle and the bull's-eye?
3.A golf ball rolls off a horizontal cliff with an initial speed of 14.0 m/s. The ball falls a vertical distance of 12.7 m into a lake below.(a) How much time does the ball spend in the air? (b) What is the speed v of the ball just before it strikes the water?
4.A rocket is fired at a speed of 85.0 m/s from ground level, at an angle of 38.0
In: Physics
Oil Well Supply offers a 7 percent coupon bond with semiannual payments and a yield to maturity of 7.73 percent. The bonds mature in 9 years. What is the market price per bond if the face value is $1,000?
$1,401.26
$1,016.95
$1,401.86
$953.88
$953.28
In: Finance
From load analysis, the following are the factored design forces result: Mu = 440 KN-m, Vu = 280 KN. The beam has a width of 400 mm and a total depth of 500 mm. Use f’c = 20.7 MPa, fy for shear reinforcement is 275 MPa, fy for main bars is 415 MPa, concrete cover to the centroid of the bars both in tension and compression is 65 mm, steel ratio at balanced condition is 0.02, lateral ties are 12 mm diameter. Normal weight concrete.
A. Determine the required spacing of transverse reinforcement due to the factored shear in mm
B. Calculate the required area of tension reinforcement in mm2 due to the factored moment, Mu
C. Calculate the required area of compression reinforcement in mm2 due to the factored moment, Mu
In: Mechanical Engineering
Describe a technique that can be used to break a columnar transposition cipher (besides brute force)?
In: Computer Science
Think about your place of work, your household or your school. Then, come up with 2 examples of efficiency (i.e, what you/they do well) and explain why you consider it efficient, AND 2 examples of inefficiency (i.e, what you/they do NOT do as well as you are capable of) and explain why it is inefficient. For the inefficiency, explain how you would solve each of those problems (correct the inefficiencies). When you reply to others, offer suggestions, input and advice - maybe you experienced something similar.
In: Economics
QUESTION 15
We need to write a function that calculates the power of x to n e.g. power(5,3)=125.
Which of the following is a right way to define power function?
______________________________________________________________
int power(int a, int b) { int i=0, p=1; for(i=b;i>=1;i--) p*=a; return p; } ______________________________________________________________ |
||
int power(int a, int b) { int i=0, p=0; for(i=1;i<=b;i--) p=p*a; return p; } ______________________________________________________________ |
||
int power(int a, int b) { int i=0, p=1; for(i=b;i>=1;i--) a*=p; return p; } ______________________________________________________________ |
||
int power(int a, int b) { int i=0, p=1; for(i=a;i>=1;i--) p=p*b; return p; } ______________________________________________________________ |
In: Computer Science
In: Psychology
In: Computer Science
Three entrepreneurs plan to open a copy shop. It costs $5000 per year to rent a copier. It costs $0.03 per copy to operate the copier. Other fixed costs of running the store will amount to $400 per month. The planned price per copy is $0.10. The shop will be open 365 days per year. Each copier can make up to 100,000 copies per year.
SHOW THE FOLLOWING IN EXCEL( show the formulas and calculation)within excel !!! THANK YOU SO SO MUCH!
In: Operations Management
I understand how electrons initially move into another's vicinity, but nowhere can I find a fathomable answer to this. Also, does the pairs forming 'a condensate' mean a Bose-Einstein condensate?
In: Physics