Benutzerspezifische Werkzeuge
Sie sind hier: Startseite Informatik Tutorium WS 2011/12 Folien Person.java

Person.java

19.01.2010, Fabian Schmich

Person.java — Java source code, 0Kb

Dateiinhalt

package tutorial;

public class Person {
	
	private String name;
	
	public Person() {
		this.name = null;
	}
	
	public Person(String initialName) {
		this.name = initialName;
	}
	
	public void print() {
		System.out.println("Person: " + getName());
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String newName) {
		this.name = newName;
	}
	
	public boolean equals(Person other) {
		return this.name.equalsIgnoreCase(other.name);
	}
	
	public static void main(String[] args) {
		Person fabi = new Person("Fabi");
		fabi.print();
		System.out.println(fabi.isSamePerson(fabi));
	}

}
Artikelaktionen
« Februar 2012 »
Februar
MoDiMiDoFrSaSo
12345
6789101112
13141516171819
20212223242526
272829