summaryrefslogtreecommitdiff
path: root/homework.txt
blob: 50521c504ad7223c2fee6127d1011386e3a652fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
City Pantry wants a simple program to be written that searches its database of vendors for menu items available given day, time, location and a number of covers. Each vendor has a name, postcode and a maximum number of covers it can serve at any time. Items on vendor menus each have a name, a list of allergies and the advance time needed for ordering the item.

Your task is to write a console application that takes four input parameters:

    filename - input file with the vendors data
    day      - delivery day (dd/mm/yy)
    time     - delivery time in 24h format (hh:mm)
    location - delivery location (postcode without spaces, e.g. NW43QB)
    covers   - number of people to feed
    
and prints a list of item names (and item-specific allergens) available for order given the following rules:

    1. vendor must be in the delivery area, e.g. vendor with a postcode starting "NW" can only deliver to a postcode starting with "NW", etc.
    2. vendor must be able to serve the requested number of covers
    3. item advance time must be less or equal to the difference between the search time and the actual time of the delivery

The input file is provided in the following EBNF-like text format:
    
    vendors      = { vendor, new line, items, new line } EOF
    vendor       = name, ";", postcode, ";", max covers
    items        = { item, new line }
    item         = name, ";", allergies, ";", advance time
    name         = /[A-Za-z ]*/
    postcode     = /[A-Za-z][A-Za-z0-9]*/
    max covers   = /\d*/
    advance time = /\d\dh/
    new line     = "\r\n"


Here's an example input file:

    Grain and Leaf;E32NY;100
    Grain salad;nuts;12h

    Wholegrains;SW34DA;20
    The Classic;gluten;24h

    Ghana Kitchen;NW42QA;40
    Premium meat selection;;36h
    Breakfast;gluten,eggs;12h

    Well Kneaded;EC32BA;150
    Full English breakfast;gluten;24h
    

Calling the application with the above input on 20/10/15 at 12 AM and the parameters "input 21/10/15 11:00 NW43QB 20" would print the following lines:

    Breakfast;gluten,eggs
    
Or, calling the application with the above input on 20/10/15 at 12 AM and the parameters "input 24/10/15 11:00 NW43QB 20" would print the following lines:

    Premium meat selection;;
    Breakfast;gluten,eggs
    

Structure your code as if this was a real, production application. You may however choose to provide simplified implementations for some aspects (e.g. in-memory persistence instead of a full database, if you think any persistence is required at all).

State any assumptions you make as comments in the codebase. If any aspects of the above specification is unclear then please also state, as comments in the source, your interpretation of the requirement.

The purpose of the exercise is to evaluate your approach to software development covering among other things elements of Object Oriented Design, Software Design Patterns and Testing. This exercise is not time bounded.

Complete the exercise in PHP. You are free to implement any mechanism for feeding input into your solution (for example, using hard coded data within unit test). You should provide sufficient evidence that your solution is complete by, as a minimum, indicating that it works correctly against the supplied test data.

Please, do not use any external libraries to solve this problem, but you may use external libraries or tools for building or testing purposes. Specifically, you are encouraged to use PHPUnit to test your code.