LoginSignup
0
0

More than 3 years have passed since last update.

オブジェクト思考

Last updated at Posted at 2019-05-15
ruby
class Person
   def name 
     "私は、ピーターだよ"
   end 

  def brain
      "計算する"
   end
 
   def tall
      170
   end
   def weight
       "60kg"
   end
   def walk
      "トコトコ"
   end

end

person = Person.new
person.name
person.brain
person.tall
person.weight
person.walk
javascript

class Person{
 constructor(name,age,tall){
  this.name = name
  this.age = age
  this.tall = tall

 }

 evaluation(){
   var score = this.age * this.tall
   if (score >= 80){
    console.log("cool") 
   }else{
     console.log("not so cool")
   } 
 }
}

bob = new Person("bob",23,170)

console.log(bob.name) # bob

console.log(bob.evaluation) # cool 



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0