Last active
August 29, 2015 14:01
-
-
Save salzig/a886ff799cb7634a03bb to your computer and use it in GitHub Desktop.
Person Class
This file contains hidden or 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
class Person { | |
private String name; | |
public Person(String name) { | |
this.name = name; | |
} | |
public Person() { | |
this("Keks"); | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(name) { | |
this.name = name; | |
} | |
} | |
new Person(); | |
Person person = new Person("Peter"); | |
person.getName(); | |
person.setName("LOL"); |
This file contains hidden or 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
<?php | |
class Person { | |
function __construct($name="Keks") { | |
$this->name = $name; | |
} | |
function getName() { | |
return $this->name; | |
} | |
function setName($name) { | |
$this->name = $name; | |
} | |
} | |
new Person(); | |
$person = new Person("Peter"); | |
$person->getName(); | |
$person->setName("LOL"); |
This file contains hidden or 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
class Person | |
def initialize(name="Keks") | |
@name = name | |
end | |
def name | |
@name | |
end | |
def name=(name) | |
@name = name | |
end | |
end | |
Person.new | |
person = Person.new("Peter") | |
person.name | |
person.name = 'LOL' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment