diff --git a/piste3d.rb b/piste3d.rb new file mode 100644 index 0000000..6a54c39 --- /dev/null +++ b/piste3d.rb @@ -0,0 +1,24 @@ +require './piste.rb' + +class Piste3d < Piste + def initialize(x,y,z) + @x = x + @y = y + @z = z + end + + def to_s + "(#{@x}, #{@y}, #{@z})" + end + + def etaisyys_origosta + Math.sqrt(@x*@x + @y*@y + @z*@z) + end + + def siirra(dx, dy, dz) + @x += dx + @y += dy + @z += dz + end + +end \ No newline at end of file diff --git a/varipiste.rb b/varipiste.rb new file mode 100644 index 0000000..fd61500 --- /dev/null +++ b/varipiste.rb @@ -0,0 +1,14 @@ +require './piste.rb' + +class Varipiste < Piste + def initialize(x, y, color) + @x = x + @y = y + @color = color + end + + def to_s + "(#{@x}, #{@y}) #{@color}" + end + +end \ No newline at end of file