JAVA for DUMMIES (Game Development) You're the lead programmer
at a AAA studio making a sequel to the big
hit game, Zeldar 2. You've been challenged to implement player
movement in dungeons. The
game is top-down, with dungeons modeled as a 2d grid with walls at
the edges. The player's
location is tracked by x,y values correlating to its row and column
positions. Given the current
position of the player and a sequence of input commands: w,a,s,d
you must determine the new
position of the player. The player must not be able to move outside
the walls of the dungeon
(i.e. grid)
Facts
● the player's position is modeled using two integer values (x,
y)
● x represents the column position, left-right axis
● top-left corner is (0,0)
● y represents the row position, up-down axis
● “w” move up by decreasing y by 1
● “a” move left by decreasing x by 1
● “s” move down by increasing y by 1
● “d” move right by increasing x by 1
● if an input attempts to move player off grid, then ignore that
move.
Input
The first input is the number of test cases. Each test case
contains three lines of inputs. The first
line is two positive integers that represent the dungeon's grid
size, rows (length) columns
(width). The second line is two non-negative integers representing
the player's position in the
dungeon grid, x,y. The third line represents the sequence of player
movements "w", "s", "a", "d".
Output
The program should print the final location of the player in the
form of <x> <y>, where “x” and
“y” are the coordinates within the dungeon grid.
Sample Input Sample Output
2
4 4 2 2
2 3
s s s w
10 10 8 4
9 4
s d w a
In: Computer Science
construct a bitmap index for the color column.
Please please show steps or explain what you did as i really want to learn how to do this.
| RecordID | Date | Color | Part Number |
| 1 | 30-03-2014 | Tiger stripes | WTL-538 |
| 2 | 29-09-2014 | Blue | LER-137 |
| 3 | 04-05-2014 | Green | UGN-537 |
| 4 | 18-03-2014 | Tiger stripes | GBD-403 |
| 5 | 10-10-2014 | Green | IAJ-568 |
| 6 | 18-12-2014 | Red | HOE-123 |
| 7 | 05-04-2014 | Tiger stripes | LFT-811 |
| 8 | 16-01-2014 | Tiger stripes | XAV-564 |
| 9 | 11-12-2014 | Red | OHJ-400 |
| 10 | 07-04-2014 | Blue | BKX-628 |
| 11 | 27-11-2014 | Green | FZX-549 |
| 12 | 04-04-2014 | Blue | SJM-622 |
| 13 | 15-08-2014 | Red | XVC-474 |
| 14 | 14-03-2014 | Tiger stripes | UQR-421 |
| 15 | 20-04-2014 | Tiger stripes | CFT-658 |
| 16 | 31-07-2014 | Green | EUV-759 |
| 17 | 05-06-2014 | Tiger stripes | XSG-479 |
| 18 | 19-03-2014 | Blue | ODD-953 |
| 19 | 25-05-2014 | Green | YDS-862 |
| 20 | 10-09-2014 | Red | LTP-337 |
| 21 | 11-09-2014 | Tiger stripes | BTL-198 |
| 22 | 25-04-2014 | Blue | ZNO-843 |
| 23 | 24-03-2014 | Green | TOX-402 |
| 24 | 28-08-2014 | Red | FKL-572 |
| 25 | 10-11-2014 | Red | PVT-512 |
| 26 | 15-03-2014 | Tiger stripes | ZLM-790 |
| 27 | 14-06-2014 | Tiger stripes | PER-701 |
| 28 | 07-11-2014 | Green | CLU-499 |
| 29 | 23-04-2014 | Red | YJV-990 |
| 30 | 19-11-2014 | Blue | JQR-979 |
| 31 | 02-02-2014 | Green | HZK-103 |
| 32 | 04-08-2014 | Green | PRK-631 |
| 33 | 25-06-2014 | Red | XBL-745 |
| 34 | 03-09-2014 | Green | NXK-247 |
| 35 | 06-03-2014 | Blue | PDJ-970 |
| 36 | 22-04-2014 | Green | TUM-443 |
| 37 | 19-11-2014 | Red | LZP-290 |
| 38 | 10-11-2014 | Red | WJQ-620 |
| 39 | 09-11-2014 | Red | OZF-584 |
| 40 | 01-12-2014 | Blue | ALF-413 |
| 41 | 08-06-2014 | Red | IIV-220 |
| 42 | 09-04-2014 | Red | CNW-296 |
| 43 | 25-10-2014 | Tiger stripes | YKB-311 |
| 44 | 30-05-2014 | Tiger stripes | ACA-257 |
| 45 | 15-02-2014 | Red | TXE-796 |
| 46 | 22-03-2014 | Tiger stripes | ONN-909 |
| 47 | 18-12-2014 | Red | VHQ-888 |
| 48 | 09-02-2014 | Green | DOL-764 |
| 49 | 22-09-2014 | Tiger stripes | KKI-825 |
| 50 | 03-07-2014 | Red | BPE-622 |
In: Computer Science
**The course name MIS Ethics**
Write a paragraph for each of the following titles with APA resources style
1-Piracy
2-Cyber crime (copyright, hacking, fraud, identity theft, computer viruses)
In: Computer Science
Write a JAVA program that asks a user to specify the number of months, investment amount and compound interest rate in % (per annum)
• Your program should then print each month, starting balance, interest earned and ending balance
• Your program is not expected to handle more than 5 months
• The balance and ending balance should be printed rounded to 2 decimal places
• You should utilise String.format() to display each line of the output. This function can be used to evenly space the output and also print doubles to a certain precision
• Text written in red below indicates user input
WANTED OUTCOME
Enter number of months: 5
Enter amount: 10
Enter interest rate (%): 6
| Month | Opening Balance | Interest | Closing Balance |
| 1 | 10.00 | 0.05 | 10.05 |
| 2 | 10.05 | 0.05 | 10.10 |
| 3 | 10.10 | 0.05 | 10.15 |
| 4 | 10.15 | 0.05 | 10.20 |
| 5 | 10.20 | 0.05 | 10.25 |
In: Computer Science
Write down what you did to accomplish each task. 1. Inspect /etc/passwd find your account. 2. Inspect /etc/shadow. What is each field displaying? 3. Add a new user to your system. Call the user "user1" with password "user" . 4. How do you inspect your environment variables. 5. Install openssh server 6. Check to see if it is up and running.
In: Computer Science
using java write a program
As the title described, you should only use two stacks to
implement a queue's actions. DO NOT use any other data structure
and push, pop and top should be O(1) by AVERAGE.
The queue should support push(element), pop() and top() where pop
is pop the first(a.k.a front) element in the queue.
Both pop and top methods should return the value of first
element
example
push(1)
pop() // return 1 push(2)
push(3)
top() // return 2 pop() // return 2
In: Computer Science
***JAVA LANGUAGE, NO CHANGES NEEDED FOR THE Movie CLASS. USE THIS AS A REFERENCE***
public class Movie {
private String title;
private int length;
private static int numMovies = 0;
public Movie() {
this("", 0);
}
public Movie(String title, int length) {
this.title = title;
this.length = length;
++numMovies;
}
public String getTitle() { return this.title; }
public int getLength() { return this.length; }
public static int getNumMovies() { return numMovies; }
public void setTitle(String title) {
this.title = title;
}
public boolean setLength(int length) {
if (length > 0) {
this.length = length;
return true;
}
else {
return false;
}
}
}
***IMPLEMENTATION CLASS BELOW HAS 3 BLOCKS OF CODE NEEDED. LOOK FOR THE COMMENTS LABELED "BLOCK"***
import javax.swing.JOptionPane;
public class TheatreIncomplete {
public static void main(String[] args) {
final int NUM_MOVIES = 5;
Movie[] movies = new
Movie[NUM_MOVIES];
int x = 0;
do {
/** START:
BLOCK #1
* In
the block below, enter code that will first check if there is room
to enter another movie in the
*
movies array. If there is, call the add the movie to the array
using the inputMovie() method.
* Else,
if there is not, display an error message to the user letting them
know the maximum nubmer of movies
* that
can be entered.
* Hint:
To check the number of movies already entered, use the
getNumMovies() static method
*/
/** END:
BLOCK #1
**/
}
while
(JOptionPane.showConfirmDialog(null, "Enter another movie?") ==
JOptionPane.YES_OPTION);
Movie shortestMovie =
getShortest(movies);
printSummary(movies,
shortestMovie);
}
private static Movie inputMovie() {
Movie aMovie = new
Movie();
aMovie.setTitle(JOptionPane.showInputDialog(null,
"Enter the title for movie " + Movie.getNumMovies() + ": "));
int length;
boolean isLengthSet =
false;
do {
try {
length
= Integer.parseInt(JOptionPane.showInputDialog("Enter the length of
" + aMovie.getTitle() + " in (minutes)"));
}
catch
(NumberFormatException e) {
length
= -1;
}
isLengthSet =
aMovie.setLength(length);
if
(!isLengthSet) {
JOptionPane.showMessageDialog(null,
"Sorry, you entered an invalid movie length. Please try
again.");
}
} while(!isLengthSet);
return aMovie;
}
private static Movie getShortest(Movie[] movies)
{
Movie aMovie = null;
if (movies.length > 0)
{
/** START:
BLOCK #2
* In
the block below, enter code that will find the movie object
containing the shortest length
* Hint:
You will need to loop through all movies to find the shortest
*/
/** END:
BLOCK #2 **/
}
return aMovie;
}
private static void printSummary(Movie[] movies,
Movie shortestMovie) {
String summary="**Movie
Summary**\n";
/** START: BLOCK #3
* First, using the
summary variable declared above, loop through all of the movies
entered, appending the title of each
* movie to the summary.
Then, append to the summary the number of movies entered, the title
of the shortest movie
* and the length of the
shortest movie
* Hint: To get the number
of movies entered, use the getNumMovies() static method
* Hint: To get the title
and length of the shortest movie, use the object reference passed
into the method
*/
/** END: BLOCK #3 **/
JOptionPane.showMessageDialog(null,
summary);
}
}
If you are not familiar with JOptionPane you can just code with Scanner and I will change it. Thank you.
In: Computer Science
In: Computer Science
As you consider computer hardware and software, what hardware element do you think impact software performance the most?
In: Computer Science
*Need to write the pseudocode for this given C++ code*:
public:
slist(): head_(nullptr), size_(0) {}
void prepend(int data)
{
snode* newnode = new
snode(data, head_);
head_ = newnode;
++size_;
}
bool empty() const
{
return size_ == 0;
}
size_t size() const{
return size_;
}
friend std::ostream& operator
<<(std::ostream& os, const slist sli){
if(sli.empty()){
return os << "list empty\n";
}
snode* p =
sli.head_;
while(p!=
nullptr){
os << *p << "\n";
p=p->next_;
}
return os;
}
int get_largest() const
{
snode*p = head_;
int largest =
p->data_;
while(p !=
nullptr){
if (p->data_ > largest)
{
largest = p->data_;
}
p = p->next_;
}
return largest;
}
bool is_greater(int n){
return
is_greater_helper(head_,n);
}
bool is_greater_helper(snode* p ,int n){
if(p->next_ ==
nullptr){return n > p->data_;}
return n >
p->data_ && is_greater_helper(p->next_, n);
}
In: Computer Science
How is testing a software system like inspecting a house?
In: Computer Science
You were introduced to control structures - such as IF-ELSE statement, WHILE and FOR loops. Describe what they do and why are control structures important to programming?
In: Computer Science
mention some RFID anti-collision protocols ?
In: Computer Science
3. To get some idea on what is involved in digital transmission of multimedia traffic, complete the following:
3.1. In PAM encoding, the general rule is that we need to sample at
twice the bandwidth. In addition, if we use n bits for each sample,
we can represent 2n loudness (amplitude) levels. What transmission
speed would you need if you wanted to encode and transmit, in real
time and without compression, two-channel music with a bandwidth of
20 kHz and 40,000 loudness levels?
3.2. How much disk space would your require to store 30 minutes of
digital music as you calculated above?
3.3. Assume that the 30 minutes of uncompressed digital music is to
be transmitted over a DS-0 digital circuit at 64 Kbps. How long
will it take to complete the transmission? Express you result in
hours/minutes if necessary.
In: Computer Science
1, Considering using sorted and unsorted array as priority queue to do sorting. For an input array, we insert each element to a PQ and remove them out to an output array. Please write the arrays below:
Input array: 2,7,5,3
Input array: 2,7,5,3
2, If I use upheap strategy to construct a heap(array as implementation) from above array, what is the array of the heap of each step?
In: Computer Science