Created
January 1, 2013 17:46
-
-
Save gdetrez/4428913 to your computer and use it in GitHub Desktop.
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 Main { | |
public static void main(String[] argv) { | |
Arme epee = new Arme(10, "Magic epee"); | |
Arme fusil = new Arme(30, "fusil"); | |
System.out.print("J'ai une "); | |
System.out.print(epee.name); | |
System.out.print(" de force "); | |
System.out.println(epee.force); | |
System.out.println(epee); | |
System.out.println(fusil); | |
} | |
} | |
class Arme { | |
int force; | |
String name; | |
public Arme(int force, String name) { | |
this.force = force; | |
this.name = name; | |
} | |
public String toString() { | |
return this.name + " <force=" + this.force + ">"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment