Google Interview Question for Software Developers

Team: Nest Labs
Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
of 0 vote

assuming the spaceship has a class that has the spaceship properties and the position x and y of the spaceship:

struct Positon{
  var x:Float?
  var y:Float?
  var z:Float?

protocol Firing{
   func Fire(destination:Position)

class Spaceship:Fire{
    var location:Position?
    var rotation: Float?
    var bullets:[Bullets]?
    func Fire(velocity:Float){
          for i in 0..<bullets.count{
              bullets[i].position.x += velocity
              bullets[i].position.y += velocity
              bullets[i].postion.y  += velocity

class Bullet{

    var position: Position?
    var velocity: Float?


class Game{

   let bullets:[Bullets]?
   let spaceship:[Spaceship]?
   //this method will be called in a loop updating the time
   func updateTime(timeInterval:Float, withDelay:Float ){

     while(game is in progress && Quit has not been pressed && Game is not sleeping)
        the postion of the bullet will be updated on each iteration of the loop
         //set the ship to a initial location and rotatino
         let newShip = Spaceship(location:Position(0,40,20), rotation(M_PI))
         //fire bulelts at the rate of 50 
          timeInterval = newtime + delay

         also you want to render the ship and do any physics here



- Anonymous August 23, 2017 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More