Skip to content

Instantly share code, notes, and snippets.

View Naomi-Dennis's full-sized avatar

Naomi Dennis Naomi-Dennis

  • 8th Light
View GitHub Profile
class ShopItem
attr_reader :value, :name
def initialize(value, name)
@value = value
@name = name
end
end
# -- snip --
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 |
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 |
class ShopItem
attr_reader :value, :name
def initialize(value, name)
@value = value
@name = name
end
end
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"
class SubwayTrain
attr_accessor :averageSpeed, :subwayCar, :speed, :subwayCars
def initialize
self.averageSpeed = 17
self.speed = 0;
self.subwayCars = [];
end
def allowPassengersOnBoard
class SubwayTrain
attr_accessor :averageSpeed, :subwayCar, :speed, :subwayCars
def initialize
self.averageSpeed = 17
self.speed = 0;
self.subwayCars = [];
end
def allowPassengersOnBoard
myLoyaltyPoints = 50
itemPrice = new ShopItem(100)
total = calculateTotal(itemPrice, myLoyaltyPoints)
function calculateTotal(price, loyaltyPoints) {
return calculateDiscount(price, loyaltyPoints) + calculateTip(price) + calculateSalesTax(price)
}
loyaltyPoints = 50
price = new ShopItem(100)
total = calculateDiscount(price, loyaltyPoints)
total = calculateTip(price)
total = calculateSalesTax(price)
class Passenger {
constructor(name, flightClass) {
this.name = name;
this.flightClass = flightClass;
}
}
let rawListOfPassengers = Array.from(document.querySelectorAll("form div"));
let allPassengers = [];