Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Your name
# Ruzeka Uddin

Please write your full name here to make it easier to find your pull request.

# User stories

Please list which user stories you've implemented (delete the ones that don't apply).

- [ ] User story 1: "I would like to see a list of dishes with prices"
- [ ] User story 2: "I would like to be able to select some number of several available dishes"
- [ ] User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order"
- [ * ] User story 1: "I would like to see a list of dishes with prices"
- [ *] User story 2: "I would like to be able to select some number of several available dishes"
- [ *] User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order"
incompleted final testing stage
- [ ] User story 4: "I would like to receive a text such as "Thank you! Your order was placed and will be delivered before 18:52" after I have ordered"

# README checklist
Expand Down
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ Takeaway Challenge

```

Instructions
## Task
-------
To write a Takeaway programme which will include a menu that lists dishes & prices of each dish. Customers will be able to use the programme to place an order & select several dishes they want with quantities, the programme will be able to calculate the total cost of the order as well.
I will be using Twilio in order to send text messages to customers to inform them when their order will be delivered. Within the testing process, I will try to use stubs and doubles in order to isolate my tests.

* Feel free to use google, your notes, books, etc. but work on your own
* If you refer to the solution of another coach or student, please put a link to that in your README
* If you have a partial solution, **still check in a partial solution**
* You must submit a pull request to this repo with your code by 9am Monday morning

Task
-----

* Fork this repo
* Run the command 'bundle' in the project directory to ensure you have all the gems
* Write a Takeaway program with the following user stories:
## Instructions
----------------
Instructions
Clone this repository to your desired location,
Run the command 'bundle' in the project directory to ensure you have all the gems.
Run RSpec in the `takeaway_challenge` directory in order to run the unit tests.

## User Story
```
As a customer
So that I can check if I want to order something
Expand All @@ -47,6 +45,17 @@ So that I am reassured that my order will be delivered on time
I would like to receive a text such as "Thank you! Your order was placed and will be delivered before 18:52" after I have ordered
```

## Domain Model Table
------------------------------------
| Objects | Messages |
| -------------- | ------------- |
| Menu/dishes | list of dishes |
| Prices | list prices of dishes|
| Order | place an order |
| Text | receive texts |
-----------------------------------


* Hints on functionality to implement:
* Ensure you have a list of dishes with prices
* The text should state that the order was placed successfully and that it will be delivered 1 hour from now, e.g. "Thank you! Your order was placed and will be delivered before 18:52".
Expand Down
30 changes: 30 additions & 0 deletions lib/menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Menu
attr_reader :lists_dishes

def initialize
@list_hash = {}
end

def lists_dishes
@List_hash =
{ "Cod" => 11.0,
"Rock" => 13.0,
"Haddock" => 13.0,
"Plaice" => 13.0,
"Skate" => 18.0,
"Code Roe" => 3.60,
"Fish Cake" => 3.0,
"Chips" => 3.80,
"chip Roll" => 4.50,
}
end

def view_dishes
@list_hash.each { |item, price| puts "#{item} £#{price}" }
end

def check_availability(item)
message = "Dish not available. Please make a new selection."
raise message if @list_hash[item].nil?
end
end
20 changes: 20 additions & 0 deletions lib/order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'menu'
attr_accessor :total, :lists_dishes

class Order

def initialize(total, lists_dishes)
@total = 0
@lists_dishes = []
end

def add(dish)
@lists_dishes << "#{dish.name} = £#{dish.price}"
@total += dish.price
end

def add(dish)
@lists_dishes << "#{dish.name} = £#{dish.price}"
@total += dish.price
end
end
22 changes: 22 additions & 0 deletions spec/menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../lib/menu'

describe Menu do

describe "#lists_dishes" do
menu = Menu.new
it' shows a list of all dishes with prices' do
expect(subject).to respond_to(:lists_dishes)
end
end

describe '#check_availability' do
menu = Menu.new
it 'raises an error when item is not available' do
expect { subject.check_availability('Fish Cake') }.to raise_error 'Dish not available. Please make a new selection.'
end
end

end



22 changes: 22 additions & 0 deletions spec/order_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../lib/order'

describe Order do
let(:dish) { double :dish, :name => "Cod", :price => 11.0 }
it 'has a default total of 0' do
expect(subject.total).to eq 0
end

it 'should create an order of dishes from menu' do
expect(subject.order).to eq []
end

it 'can add items to the order' do
subject.add(dish)
expect(subject.items).to include("Cod = £11")
end

it 'updates the total with each added item' do
subject.add(dish)
expect(subject.total).to eq (5)
end
end