diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5309762cb2..67c505715e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ -# Your name +# Ruzeka Uddin Please write your full name here to make it easier to find your pull request. @@ -6,9 +6,10 @@ Please write your full name here to make it easier to find your pull request. 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 diff --git a/README.md b/README.md index dbcb154e43..89985b8a9c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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". diff --git a/lib/menu.rb b/lib/menu.rb new file mode 100644 index 0000000000..1a44946d9f --- /dev/null +++ b/lib/menu.rb @@ -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 \ No newline at end of file diff --git a/lib/order.rb b/lib/order.rb new file mode 100644 index 0000000000..3db35ea407 --- /dev/null +++ b/lib/order.rb @@ -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 \ No newline at end of file diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb new file mode 100644 index 0000000000..5a8eb3347e --- /dev/null +++ b/spec/menu_spec.rb @@ -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 + + + diff --git a/spec/order_spec.rb b/spec/order_spec.rb new file mode 100644 index 0000000000..9677f4f8a6 --- /dev/null +++ b/spec/order_spec.rb @@ -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 \ No newline at end of file