fork(121) download
  1. class Team {
  2. Member member;
  3. public Team(Member member) { // who is in this Team?
  4. this.member = member; // this 'member' is in this Team!
  5. }
  6.  
  7. public static void main(String[] args) {
  8. Member myMember = new Member("Aurieel", "light", 10, 1);
  9. Team myTeam = new Team(myMember); // success! Aureel now belongs to a team!
  10. System.out.println(myTeam.member.getName());
  11. System.out.println(myTeam.member.getType());
  12. System.out.println(myTeam.member.getLevel());
  13. System.out.println(myTeam.member.getRank());
  14. }
  15. }
  16.  
  17. class Member {
  18. private String name;
  19. private String type;
  20. private int level;
  21. private int rank;
  22.  
  23. public Member(String name, String type, int level, int rank) {
  24. this.name = name;
  25. this.type = type;
  26. this.level = level;
  27. this.rank = rank;
  28. }
  29.  
  30. public String getName() {
  31. return this.name;
  32. }
  33.  
  34. public String getType() {
  35. return this.type;
  36. }
  37.  
  38. public int getLevel() {
  39. return this.level;
  40. }
  41.  
  42. public int getRank() {
  43. return this.rank;
  44. }
  45. }
  46.  
  47.  
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Aurieel
light
10
1