This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShopItem | |
attr_reader :value, :name | |
def initialize(value, name) | |
@value = value | |
@name = name | |
end | |
end | |
# -- snip -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def items | |
[ShopItem.new(20, "Paper"), | |
ShopItem.new(50, "Ball"), | |
ShopItem.new(40, "Book"), | |
ShopItem.new(4, "Chips")] | |
end | |
def find_item(item_name) | |
items.select do | item | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def items | |
[ShopItem.new(20, "Paper"), | |
ShopItem.new(50, "Ball"), | |
ShopItem.new(40, "Book"), | |
ShopItem.new(4, "Chips")] | |
end | |
def find_item(item_name) | |
items.select do | item | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShopItem | |
attr_reader :value, :name | |
def initialize(value, name) | |
@value = value | |
@name = name | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if item == "Paper" | |
money = perform_transaction(money, item, 20) | |
elsif item == "Ball" | |
money = perform_transaction(money, item, 50) | |
elsif item == "Book" | |
money = perform_transaction(money, item, 40) | |
elsif item == "Chips" | |
money = perform_transaction(money, item, 4) | |
else | |
puts "We don't sell that item" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubwayTrain | |
attr_accessor :averageSpeed, :subwayCar, :speed, :subwayCars | |
def initialize | |
self.averageSpeed = 17 | |
self.speed = 0; | |
self.subwayCars = []; | |
end | |
def allowPassengersOnBoard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubwayTrain | |
attr_accessor :averageSpeed, :subwayCar, :speed, :subwayCars | |
def initialize | |
self.averageSpeed = 17 | |
self.speed = 0; | |
self.subwayCars = []; | |
end | |
def allowPassengersOnBoard | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myLoyaltyPoints = 50 | |
itemPrice = new ShopItem(100) | |
total = calculateTotal(itemPrice, myLoyaltyPoints) | |
function calculateTotal(price, loyaltyPoints) { | |
return calculateDiscount(price, loyaltyPoints) + calculateTip(price) + calculateSalesTax(price) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loyaltyPoints = 50 | |
price = new ShopItem(100) | |
total = calculateDiscount(price, loyaltyPoints) | |
total = calculateTip(price) | |
total = calculateSalesTax(price) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Passenger { | |
constructor(name, flightClass) { | |
this.name = name; | |
this.flightClass = flightClass; | |
} | |
} | |
let rawListOfPassengers = Array.from(document.querySelectorAll("form div")); | |
let allPassengers = []; |
NewerOlder