Amazon Interview Question for Software Engineer / Developers


Team: video
Country: United Kingdom
Interview Type: Phone Interview




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

air traffic control system is a classic example of mediator design pattern.
1) Define an interface for mediator.
2) Define another interface for client.
3) Define concrete impl for the mediator interface
4) Define concrete impl for the flight interface.
Each flight object needs to register with the mediator.

- king July 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Ya, fundementally using 'Mediator' pattern i guess. Three fundemental objects i see are 'Aircraft' and 'ATS Controller' and 'Common Resources'. 'Aircraft' basically seeks permissions for various stages and Controller fundementaly validates and grants. In the process of validation, controller communicates with other 'Aircraft' objects and interacts with 'common resources'

Various operations/member functions across these classes could be as follows :

Aircraft :
-pre-flight activities
- take-off
-inFlight
- descent
-landing

Note - Every stage is time-bound, sending/receiving grants based on start/end times.

Controller/base

- Weather report engine (common for location)
-Grant pre-flight
-grant take-off
-Monitor inFlight route
- Monitor Arrivals, departures, transits
- Two-way Communication with Controllers at other locations
- Provide Alerts (categorized based on severity)
- Address emergenies ( Ex- Engage rescue flights when needed etc)
- Constantly poll all aircrafts in jurisdiction.
Note - Controller class can internally use 'descision trees' to 'Grant' a given permission based on interaction with other Aircraft objects and resources.

Also for basic departure and arrival grants, a priority queue could be maintained. Priority could be defined based on how close aircraft is to the base, fuel-level, Number of passengers, etc


Common Resources:

-Runways availability/condition
- Engineering staff
- Flight safety crew


ATS system as such is mission-critical and should be extremely fault-tolerant and with Zero down-time. To meet these goals, reduncancies could be present for 'Controller' objects (say primary, secondary controllers) which ensure to give grants/alerts . Also Controllers should continously 'Poll' the black-boxes (think of them as connected IPs) for constant 'in-touch' situation.


Please let me know your opinion on this design.

- rsk October 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I found the solution on a paper named design of a air traffic control system using UML .As I am unable to post the link here, if you are interested in solution please search for "DESIGN OF FORMAL AIR TRAFFIC CONTROL SYSTEM THROUGH UML"
Not sure if I was expected to do most of these in the 45 minutes slot

- Phoenix July 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ubicc.org/files/pdf/formalATC_287.pdf

- hulk April 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.javapapers.designpattern.mediator;

public class ATCMediator implements IATCMediator {
private Flight flight;
private Runway runway;
public boolean land;

public void registerRunway(Runway runway) {
this.runway = runway;
}

public void registerFlight(Flight flight) {
this.flight = flight;
}

public boolean isLandingOk() {
return land;
}

@Override
public void setLandingStatus(boolean status) {
land = status;

}
}
package com.javapapers.designpattern.mediator;

public interface Command {
void land();
}
package com.javapapers.designpattern.mediator;

public interface IATCMediator {

public void registerRunway(Runway runway);

public void registerFlight(Flight flight);

public boolean isLandingOk();

public void setLandingStatus(boolean status);
}
package com.javapapers.designpattern.mediator;

public class Flight implements Command {
private IATCMediator atcMediator;

public Flight(IATCMediator atcMediator) {
this.atcMediator = atcMediator;
}

public void land() {
if (atcMediator.isLandingOk()) {
System.out.println("Landing done....");
atcMediator.setLandingStatus(true);
} else
System.out.println("Will wait to land....");
}

public void getReady() {
System.out.println("Getting ready...");
}

}
package com.javapapers.designpattern.mediator;

public class Runway implements Command {
private IATCMediator atcMediator;

public Runway(IATCMediator atcMediator) {
this.atcMediator = atcMediator;
atcMediator.setLandingStatus(true);
}

@Override
public void land() {
System.out.println("Landing permission granted...");
atcMediator.setLandingStatus(true);
}

}
package com.javapapers.designpattern.mediator;

public class MediatorDesignPattern {
public static void main(String args[]) {

IATCMediator atcMediator = new ATCMediator();
Flight sparrow101 = new Flight(atcMediator);
Runway mainRunway = new Runway(atcMediator);
atcMediator.registerFlight(sparrow101);
atcMediator.registerRunway(mainRunway);
sparrow101.getReady();
mainRunway.land();
sparrow101.land();
}
}

- Anonymous April 25, 2020 | Flag Reply


Add a Comment
Name:

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

Books

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

Videos

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