Guest User

Untitled

a guest
Feb 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public class Character {
  2.  
  3. private String name;
  4. private char gender;
  5. private List<String> inventory = new ArrayList<String>();
  6.  
  7. public Character(String name, char gender, List<String> inventory) {
  8. this.name = name;
  9. this.gender = gender;
  10. this.inventory.addAll(inventory); // Is this a good idea?
  11. }
  12.  
  13. public String getName() {
  14. return name;
  15. }
  16.  
  17. public char getGender() {
  18. return gender;
  19. }
  20.  
  21. public List<String> getInventory() {
  22. return inventory;
  23. }
  24.  
  25. }
  26.  
  27. public class Main {
  28.  
  29. public static void main(String[] args) {
  30.  
  31. Character coolKid = new Character("Cool Kid", 'f',
  32. Arrays.asList("just", "testing"));
  33.  
  34. System.out.println(coolKid.getInventory());
  35. // returns [just, testing]
  36.  
  37. }
  38. }
  39.  
  40. return Collections.unmodifiableList(inventory);
Add Comment
Please, Sign In to add comment