• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Question from Java Exam  RSS feed

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the last assignment from an older Java Exam for my university course. If you got some free time, feel free to post your solutions to the assignment. Would be very instructive for me.
I will try my best to translate the problem to English.

You have been obligated to write an algorithm that will be used in a Space Invader-type of game to handle shots fired from the player at the enemies.
The entity of the player can only move horizontality. The enemies can move both horizontality and vertically.
The shots fired only move vertically (from the position of the player’s ship), and many shots fired can be active at the same time. The enemies and the shots  approximates with rectangles.  

Your task is to implement two methods:


a) boolean isHit(Enemy e , Bullet b ) that asks the question if an enemy (e) has been hit by a shot (b). (3p)


b) void gameRunning().  That is the game’s main method. The method should have a loop that moves the enemies, the shots fired and to call isHit() for control.  (1p)

 
Master Rancher
Posts: 1162
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL Really? If you have some time feel free to post the answer? This isn't how it works... We're not here to  answer your examquestion, try to solve it yourself and when you get stuck post a question, don't ask us to write the entire program for you. Or you could but then we charge you 150€ an hour, that's about what a medior java developer goes for in Belgium
 
Daniel Andersson
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:LOL Really? If you have some time feel free to post the answer? This isn't how it works... We're not here to  answer your examquestion, try to solve it yourself and when you get stuck post a question, don't ask us to write the entire program for you. Or you could but then we charge you 150€ an hour, that's about what a medior java developer goes for in Belgium



Well yeah i know. But you people seem to love java. Someone might think it was a fun challenge.

It's not an assignment that i would turn in, it's an problem for an old exam. But yeah I understand what you are saying.
 
Marshal
Posts: 6594
443
BSD Linux Mac OS X VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:Or you could but then we charge you 150€ an hour


@OP
Note: that is probably what Daniel does, his saying "we" doesn't involve coderanch as an entity.

But he was right about the part that you'd need to ellaborate a bit more in order to explain where you stuck.
 
Marshal
Posts: 63461
207
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know more about those Enemy objects. Actually, those questions worry me. It doesn't say which class they ought to be in. Maybe the second should be called run() instead of isRunning(), so you can write something like this:-Actually, I think you would run the player and the enemies on separate threads. And that will be €15000000000000000000000000000000000000000000000000000000 please. You'll get a 100% discount if you find more than four mistakes in what I wrote
 
Campbell Ritchie
Marshal
Posts: 63461
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody found anything wrong yet?
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!