Skip to content

Instantly share code, notes, and snippets.

@bitsmuggler
Last active August 29, 2015 14:03
Show Gist options
  • Save bitsmuggler/40cecf4b39d005a2fd56 to your computer and use it in GitHub Desktop.
Save bitsmuggler/40cecf4b39d005a2fd56 to your computer and use it in GitHub Desktop.
Übung in OOP Workshop @ejs14
/** @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