Last active
August 29, 2015 14:03
-
-
Save bitsmuggler/40cecf4b39d005a2fd56 to your computer and use it in GitHub Desktop.
Übung in OOP Workshop @ejs14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @constructor */ | |
function Person(name, age, geschlecht) { | |
this.name = name; | |
this.age = age; | |
this.geschlecht = geschlecht; | |
} | |
/** Methode */ | |
Person.prototype.getName = function() { | |
return this.name; | |
}; | |
Person.prototype.getAge = function() { | |
return this.age; | |
}; | |
Person.prototype.getGeschlecht = function() { | |
return this.geschlecht; | |
}; | |
var person1 = new Person('test1', 20, 'M'); | |
var person2 = new Person('test2', 80, 'W'); | |
var person3 = new Person('test3', 30, 'M'); | |
var persons = [person1, person2, person3]; | |
for(var i in persons) { | |
logPerson(persons[i]) | |
} | |
function logPerson(person){ | |
console.log(person.getName() + ' ' + person.getAge() + ' ' + person.getGeschlecht()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment