diff --git a/bank_transaction.rb b/bank_transaction.rb new file mode 100644 index 0000000..32380ea --- /dev/null +++ b/bank_transaction.rb @@ -0,0 +1,108 @@ +class CreditCard + def initialize(bank, cust) + @bank = bank + @cust = cust + end + + def bank() + @bank + end + def cust() + @cust + end +end + + +class BankCustomer + def initialize(name, balance) + @name = name + @balance = balance + @credit_card + end + + def balance() + @balance + end + + def deduct_funds(amount) + @balance -= amount + end + def add_funds(amount) + @balance += amount + end + def assign_card(card) + @credit_card = card + end + + def credit_card() + @credit_card + end + def get_name() + @name + end +end + + +class Bank + def initialize(name) + @BankName = name + @customers = Hash.new + end + + def withdraw(name, amount) + if @customers[name].balance > amount + @customers[name].deduct_funds(amount) + puts "withdraw success. new balance #{@customers[name].balance}" + return true + else + puts "insufficient funds" + return false + end + end + + def deposite(amount) + @customers[name].add_funds(amount) + puts "Added #{amount} to your balance. New balance is #{@balance}" + end + + def enroll_BankCustomer(name, balance) + if @customers.has_key?(name) + puts "customer already exists" + else + + cust = BankCustomer.new(name, balance) + card = CreditCard.new(self, cust) + cust.assign_card(card) + + @customers[name] = cust + puts "added customer!" + cust + end + end + + def name() + @BankName + end +end + + +class Store + def initialize(name) + @name = name + end + def sell_item(cost, card) + customer=card.cust + name = customer.get_name + card.bank.withdraw(name, cost) + end +end + +b = Bank.new("BofA") +anthony = b.enroll_BankCustomer('Anthony', 5000) +b.enroll_BankCustomer('john', 2000) +b.withdraw('Anthony', 2000) +b.withdraw('john', 3000) +anthony_card = anthony.credit_card +s = Store.new('store') + +s.sell_item(100, anthony_card) diff --git a/http_requests.txt b/http_requests.txt index 1764a22..6264e11 100644 --- a/http_requests.txt +++ b/http_requests.txt @@ -21,12 +21,19 @@ answer the following... 1. GET /movies Fill this in with what the page will look like in the browser: + + Title: A New Hope, Year: 1977 + Title: The Empire Strikes Back, Year: 1980 + Title: Return of the Jedi, Year: 1983 + - +*** They might all be on the same line since there's no

or
in the template. 2. GET /movies/1 Fill this in with what the page will look like in the browser: - + + Title: A New Hope, Year: 1977 + 3. POST /movies with params {:movie => {:title => "The Phantom Menace", :year => 1998}} @@ -35,13 +42,13 @@ Fill in what the database should look like after a post with parameters ================================================ | id | Title | Year | ================================================ -| | | | +| 1 | A New Hope | 1977 | ------------------------------------------------ -| | | | +| 2 | The Empire Strikes Back | 1980 | ------------------------------------------------ -| | | | +| 3 | Return of the Jedi | 1983 | ------------------------------------------------ -| | | | +| 4 | The Phantom Menace | 1998 | ------------------------------------------------ 4. PUT /movies/4 {:movie => {:title => "The Phantom Menace", :year => 1999}} @@ -50,18 +57,26 @@ Fill in what the database should look like after the PUT with the parameters ================================================ | id | Title | Year | ================================================ -| | | | +| 1 | A New Hope | 1977 | ------------------------------------------------ -| | | | +| 2 | The Empire Strikes Back | 1980 | ------------------------------------------------ -| | | | +| 3 | Return of the Jedi | 1983 | ------------------------------------------------ -| | | | +| 4 | The Phantom Menace | 1999 | ------------------------------------------------ 5. GET /movies Fill in what the page should look like in the browser + + Title: A New Hope, Year: 1977 + Title: The Empire Strikes Back, Year: 1980 + Title: Return of the Jedi, Year: 1983 + Title: The Phantom Menace, Year: 1999 + + +*** They might all be on the same line since there's no

or
in the template. 6. DELETE /movies/4 Fill in what the database should look like after the above request @@ -69,9 +84,9 @@ Fill in what the database should look like after the above request ================================================ | id | Title | Year | ================================================ -| | | | +| 1 | A New Hope | 1977 | ------------------------------------------------ -| | | | +| 2 | The Empire Strikes Back | 1980 | ------------------------------------------------ -| | | | +| 3 | Return of the Jedi | 1983 | ------------------------------------------------ diff --git a/interview_responses.txt b/interview_responses.txt index 3eecdbd..c9b9e91 100644 --- a/interview_responses.txt +++ b/interview_responses.txt @@ -1,9 +1,51 @@ You can write your responses here! -1. +1. One. +Pick one out of the "both" box. Whichever fruit you pick, that box is filled with those fruits (lets say apples) + this means that the box labeled orange has to be the both box -- since it's not apples, and it can't be oranges (since it's labeled wrong) -- it must be both + then that means the third box is the oranges box since it's neither both -- nor oranges. 2. +referse_string(string) + array = [] + i = string.lenth() -1 + count = 0 + for i >=0 i-- + array[count] = string[i:i+1] + count += 1 + return array.to_s 3. +Recursive: -4. \ No newline at end of file +find_sum(array) + length = array.len + sum = 0 + for i=0, i0) + temp = [] + foreach item in arrays + if item.type?(Array) + temp.append(item) + else + sum = sum + item + arrays = [] + foreach item in temp + size = item.length() + for i=0, i