class Order attr_accessor :shipping_address def initialize(shipping_address) @shipping_address = shipping_address end def print_address puts "Shipping Address: #{@shipping_address}" end end order = Order.new("123 Main St, Anytown, USA") order.print_address
class Address attr_reader :street, :city, :country def initialize(street, city, country) @street = street @city = city @country = country end def ==(other) other.is_a?(Address) && street == other.street && city == other.city && country == other.country end def to_s "#{street}, #{city}, #{country}" end end class Order attr_reader :shipping_address def initialize(shipping_address) @shipping_address = shipping_address end def print_address puts "Shipping Address: #{@shipping_address}" end end address = Address.new("123 Main St", "Anytown", "USA") order = Order.new(address) order.print_address
Address
==