Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toshi assignment #22

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assignments/assignment_demo/Toshihiko Shimasaki/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Toshihiko, Soba
141 changes: 141 additions & 0 deletions assignments/pokemonclass/Toshihiko_Shimasaki/pokemon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
class Pokemon
def initialize
@defense = 0
end
def name
@name
end

def name= newname
@name = newname
end

#health getters and setters
def current_health
@current_health
end

def current_health= newhealth
@current_health = newhealth
end

def max_health
@max_health
end

def max_health= newhealth
@max_health = newhealth
end

def damage amount
netdamage = amount - @defense
if netdamage < 0
netdamage = 0
end
@current_health = @current_health - netdamage
end

def attack
@attack
end

def defense
@defense
end

def defense= value
@defense = value
end

def full_heal
@current_health = @max_health
end

def cry
puts @cry
end

def defense value
@defense = value
end

end

class Pikachu < Pokemon
def initialize
@name = "Pikachu"
@max_health = 300
@cry = "kya"
@defense = 100
full_heal
end
def neutrize opponent
opponent.defense = 0
end
def recover
@current_health += 200
end

end

class Godzilla < Pokemon
def initialize
@name = "Godzilla"
@max_health = 999
@cry = "Gyao"
@defense = 100
full_heal
end
def fire opponent
opponent.current_health -= 200
end
def self_destruction
@current_health = 0
end

end

class Angel < Pokemon
def initialize
@name = "Angel"
@max_health = 500
@cry = "Hya"
@defense = 500
full_heal
end
def healing_love opponent
opponent.current_health = opponent.full_heal
end
def death_sentence opponent
opponent.current_health = 1
end
def self_recovery
full_heal
end
end

#fighting between Godzilla and Angel
g = Godzilla.new
a = Angel.new

puts g.current_health
puts a.current_health

a.death_sentence(g)
g.cry
puts g.current_health

g.fire(a)
a.cry
puts a.current_health

a.healing_love(g)
g.cry
puts g.current_health

g.self_destruction
g.cry
puts g.current_health



1 change: 1 addition & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0-p247
13 changes: 13 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

#For Sinatra
gem 'sinatra'
gem 'sinatra-contrib'

#To help with debugging
gem 'pry'

#To run the testing suite
gem 'capybara'
gem 'rspec'
gem 'rubocop'
75 changes: 75 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
GEM
remote: https://rubygems.org/
specs:
ast (1.1.0)
backports (3.5.0)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.0)
diff-lcs (1.2.5)
json (1.8.1)
method_source (0.8.2)
mime-types (2.1)
mini_portile (0.5.2)
multi_json (1.8.4)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
parser (2.1.7)
ast (~> 1.1)
slop (~> 3.4, >= 3.4.5)
powerpack (0.0.9)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2)
rack-protection (1.5.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
rainbow (2.0.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rubocop (0.19.1)
json (>= 1.7.7, < 2)
parser (~> 2.1.7)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.4.2)
sinatra (1.4.4)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sinatra-contrib (1.4.2)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
slop (3.4.7)
tilt (1.4.1)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
pry
rspec
rubocop
sinatra
sinatra-contrib
2 changes: 2 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
youtubesets
===========
2 changes: 2 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require './youtubesets'
run Sinatra::Application
11 changes: 11 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/edit.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>Edit set "<%=@setname%>"</h1>
<form action="/sets/<%=@setname%>" method="post">
<input type="hidden" name="_method" value="put">
<% pageoutput = "" %>
<% @videoarray.each do |dummy| %>
<% pageoutput = pageoutput + "<label>" + dummy + "</label><input type=\"checkbox\" name=\"" + dummy + "\" value=\"test\" > <br> \n\r" %>
lol
<% end %>
<% pageoutput += "<label><h2>Videos to add</h2></label><textarea name=\"morevideolist\"></textarea><input type=\"submit\"></form>" %>
<%= pageoutput %>
</form>
8 changes: 8 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/edit2.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1>edit a specific Set</h1>
<form action="/sets/<%=@setname%>" method="post">
<label>Set Name</label>
<input type="text" name="setname">
<label>List of Videos</label>
<textarea name="videolist"></textarea>
<input type="submit">
</form>
1 change: 1 addition & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Welcome To My App</h1>
15 changes: 15 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/learningerb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%#erb files are mostly made of html, with ruby tags in some places where they're needed%>
<h1>Welcome To My App</h1>

<%#Without the =, nothing will be printed. Most ruby statements, those that manipulate data, cannot print and must be run without the =%>
<% i = 2 %>

<%#With the =, the result of the expression will be printed to the page as a string%>
<%= i %>

<%#You can use string interpolation within strings like we were doing in youtubesets.rb, but it's not often as useful in erb files since you can put text outside of the ruby bracket-tags%>
<%= "#{i}" %>

<%#This line will print "#{i}" directly to the page. String interpolation only works within strings within ruby code.%>
#{i}

9 changes: 9 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/new.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<a href="/">Home</a>
<h1>Create a New Set</h1>
<form action="/sets" method="post">
<label>Set Name</label>
<input type="text" name="setname">
<label>List of Videos</label>
<textarea name="videolist"></textarea>
<input type="submit">
</form>
4 changes: 4 additions & 0 deletions assignments/sinatraapp/Toshihiko_Shimasaki/views/play.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<a href=\"/\">Home</a>
<body style="margin:0;">
<object height="100%" width="100%"><param name="movie" value="http://www.youtube.com/v/<%=@videonumber%>&autoplay=1" /><embed height="100%" src="http://www.youtube.com/v/<%=@videonumber%>&autoplay=1" type="application/x-shockwave-flash" width="100%"></embed></object>
</body>
Loading