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
// C++ styleguide: https://google.github.io/styleguide/cppguide.html | |
// in class video: https://youtu.be/p60rN9JEapg | |
#include <iostream> | |
#include "namespace.h" | |
int main(int argc, const char * argv[]) { | |
// strings are immutable | |
std::string hello = "Hello, World!\n"; | |
std::cout << hello; |
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
# use a stack to validate parenthesis completion | |
class Stack | |
def initialize | |
@store = [] | |
end | |
def push(x) | |
@store.push(x) | |
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
# Suit | |
# instance variables | |
# pip: club, heart, spade diamond | |
# rank: two, three, four... jack, queen... | |
# instance methods | |
# to_s | |
# Card | |
# instance variables | |
# suit: a Card has one Suit |
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
# ----------- Temprature Convertor ----------- | |
puts "type 1 to convert from Celsius to Fahrenheit /n or type 2 to convert from Fahrenheit to Celsius" | |
scale_chosen = gets.chomp | |
def temp(arg) | |
if arg == '1' | |
puts "enter Celsius temprature" | |
temprature = gets.chomp | |
f_temp = temprature.to_f * 9/5 + 32 | |
puts "#{temprature} degrees Celsius is #{f_temp.round(2)} degrees Fahrenheit" |