Skip to content

Instantly share code, notes, and snippets.

View sbernhardi's full-sized avatar

Soenke Bernhardi sbernhardi

View GitHub Profile
@sbernhardi
sbernhardi / rockpaper.rb
Created November 25, 2016 15:42
Rock, Paper, Scissor - the Terminal Game
def welcome
puts "
Hi, wanna play \"Rock, Paper, Scissor\"? (y/n)"
$score = [0, 0]
init(gets.chomp.split("").first.downcase)
end
def init(answer = "")
if (answer == "y")
puts " Cool. You know the rules?"
@sbernhardi
sbernhardi / cat.rb
Last active November 11, 2016 17:23
CF Ruby 01
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
puts "Mmmm, "+food+"!"
@sbernhardi
sbernhardi / fav_foods.rb
Created November 10, 2016 15:43
CF Ruby 01
def fav_foods
food_array = []
3.times do
puts "Name a favorite food."
food_array << gets.chomp
end
puts "Your favorite foods are #{food_array.join(", ")}."
end
fav_foods
@sbernhardi
sbernhardi / basicRuby02-03.rb
Last active November 10, 2016 15:43
CF Ruby 01
3.times do
puts "Hello!\n"
end
number = 0
while (number <= 10) do
p "the number is now #{number}"
number += 1
end
@sbernhardi
sbernhardi / basicRuby02-02.rb
Last active November 10, 2016 15:43
CF Ruby 01
def choose
puts "Do you like programming?"
choice = gets.chomp
if (choice.downcase == "yes" || choice.downcase == "yep" )
puts "Cool, me too!"
elsif (choice.downcase == "no")
puts "Too bad. Get lost!"
else
puts "I have no idea, what you just said."
end
@sbernhardi
sbernhardi / basicRuby02-01.rb
Last active November 10, 2016 15:43
CF Ruby 01
def choose
puts "Do you like programming?"
choice = gets.chomp
if (choice.downcase == "yes")
puts "Cool, me too!"
elsif (choice.downcase == "no")
puts "Too bad. Get lost!"
else
puts "I have no idea, what you just said."
end
@sbernhardi
sbernhardi / basicRuby01.rb
Last active November 10, 2016 15:43
CF Ruby 01
def greeting
puts "Please enter your name:"
name = gets.chomp
puts "Hi there, "+name+", 'ssup?"
end
greeting
@sbernhardi
sbernhardi / calculator.js
Last active November 10, 2016 12:29
CF Calculator
var calcStr = ""; // computation String as such - to be eval()uated at the end.
var calcDec = false; // toggle for checking if decimal point is set
var calcDone = false; // toggle for checking eval()
var operand = []; // collecting operands -> dataGathering()
var numbers = []; // collecting numbers -> dataGathering()
function dataGathering(a){
if (calcStr) {
numbers.push(parseFloat(calcStr));
@sbernhardi
sbernhardi / styles.css
Last active November 8, 2016 15:02
CF Calculator
#calculator {
font-family: monospace;
width: 320px;
height: 400px;
margin: 10px auto;
border: 5px solid #555;
padding: 5px;
border-radius: 10px;
background-color: #ddd;
}
@sbernhardi
sbernhardi / index.html
Last active November 8, 2016 15:02
CF Calculator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FutureDev's Calculator</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/styles.css">