Skip to content

Instantly share code, notes, and snippets.

@karszawa
Last active December 19, 2015 16:19
Show Gist options
  • Save karszawa/5982959 to your computer and use it in GitHub Desktop.
Save karszawa/5982959 to your computer and use it in GitHub Desktop.
後輩のプログラミングの課題が厄介な感じだったのでやってみた
# -*- coding: utf-8 -*-
class Node
attr_accessor :message, :yes, :no
def initialize(message)
@message = message
@yes = nil
@no = nil
end
def transmition
puts @message
return self if yes == nil
(gets.chomp.to_i == 0 ? @yes : @no)
end
end
start = Node.new "著作物の無断複製か?(ダウンロード・リッピングその他)"
start.yes = Node.new "私的使用のためか"
start.no = Node.new "適法"
start.yes.yes = Node.new "対象は有償の映像・音楽等か"
start.yes.no = Node.new "引用など他の著作権の例外制定に該当するか"
start.yes.no.yes = Node.new "複製としては適法 -> OK"
start.yes.no.no = Node.new "複製法侵害: 違法罰金あり懲役10年・罰金1000万円以下等 -> NG"
drm = Node.new "DRM(コピーガード・暗号型アクセスガード)外しによる複製か"
drm.no = Node.new "私的複製成立適法 -> OK"
drm.yes = Node.new "「技術的保護手段の回避規制」の対象: 違法・ただし罰則なし) -> NG"
start.yes.yes.no = drm;
start.yes.yes.yes = Node.new "対象は無断でアップされた作品か"
start.yes.yes.yes.no = drm;
start.yes.yes.yes.yes = Node.new "侵害物と知ってダウンロード(録音・録画)したか"
start.yes.yes.yes.yes.no = drm;
start.yes.yes.yes.yes.yes = Node.new "「ダウンロード刑罰化」の対象: 違法・罰則あり(懲役2年・罰金200万円以下等) -> NG"
# main
puts "[yes/no -> 1/0]"
node = start
loop do
nxt = node.transmition
break if nxt == node
node = nxt
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment