Amazon Interview Question for Software Engineer / Developers






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

I suggest using a Factory Method pattern to make the design more flexible and extendible. You can have an abstract class Clothes, which has properties such as price, brand, size, etc. and different kinds of clothes subclass it, overloading price() and brand(). This has the benefit that the store could sell objects of type Clothes, and through runtime polymorphism resolve what kind of clothes to sell. A hash table or a map in the Store class could help finding what sizes of clothes are in-stock.

To take this further, we might also consider Abstract Factory pattern to be able to sell families of clothes such as shirts, underwear, dresses, jackets, etc. and to account for more flexibility with respect to later additions of clothes to the store and modifications.

- PC May 01, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

why do we need factory methods, why not simply apparel interface being implemented by classes shirt, pant, etc... ??

- spiderman August 20, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Probably Command or Composite Pattern.

- const volatile March 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Probably not. Could you explain in detail how to use Command here?

- JX March 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Class Store
{
String location
int phone
int branch_id
String email

ArrayList<Cloth> cloth;

add(cloth)
{
//add barcode and price to Hash
}

// for purchase and return
Hash<cloth.barCode, cloth.price>

//methods that returs arraylist of clothes
ArrayList<cloth> getCloth(cloth.type)
ArrayList<cloth> getCloth(cloth.size)
ArrayList<cloth> getCloth(cloth.brand)
}

Class Cloth
{
String brand
enum size {S, M, L, XL, XXL}
enum type {TShirt, Shirt, Pant, Jeans,..}
float price
long barCode

Cloth()
Cloth(type)
}

Class Customer
{
buyCloth(Cloth.barCode, PaymentObj)
{
//get price
//returns Payment receipt number
}

returnCloth(Cloth.barCode) {}
}

Class Staff{}

Class Payment
{
int receiptN
}

Let me know if this design is good!

- R April 30, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yeah, pretty much what I also told the interviewer, But I also had a department class, for different departments like mens women's kid's etc...and had a search method in this class which was then overloaded in 2 other classes that I had for brand and type of clothing(shirt, jeans, outerwear etc) and had these classes inheriting from Department.
But this is an open ended question so I think your solution is also good enough.

- troy April 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yeah, pretty much what I also told the interviewer, But I also had a department class, for different departments like mens women's kid's etc...and had a search method in this class which was then overloaded in 2 other classes that I had for brand and type of clothing(shirt, jeans, outerwear etc) and had these classes inheriting from Department.
But this is an open ended question so I think your solution is also good enough.

- troy April 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yeah, pretty much what I also told the interviewer, But I also had a department class, for different departments like mens women's kid's etc...and had a search method in this class which was then overloaded in 2 other classes that I had for brand and type of clothing(shirt, jeans, outerwear etc) and had these classes inheriting from Department.
But this is an open ended question so I think your solution is also good enough.

- troy April 30, 2011 | Flag


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