Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Voter Simulator.
- @@political_party = {"D" => "Democrat", "R" => "Republican"}
- @@political_views = {"L" => "Liberal", "C" => "Conservative", "T" => "Tea Party", "S" => "Socialist", "N" => "Neutral"}
- # Create a valid person with a name.
- class Person
- attr_accessor :name
- def initialize(args)
- @name = args.fetch(:name)
- end
- end
- # Represents a valid voter.
- class Voter < Person
- attr_accessor :political_view
- def initialize(args)
- super(args)
- @political_view = @@political_views[args.fetch(:political_view)]
- end
- # def set_political_view(political_view)
- # @political_view = @@political_views[political_view]
- # end
- end
- # Represents a valid politician.
- class Politician < Person
- attr_accessor :political_party
- def initialize(args)
- super(args)
- @political_party = @@political_party[args.fetch(:political_party)]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement