Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Character {
- private String name;
- private char gender;
- private List<String> inventory = new ArrayList<String>();
- public Character(String name, char gender, List<String> inventory) {
- this.name = name;
- this.gender = gender;
- this.inventory.addAll(inventory); // Is this a good idea?
- }
- public String getName() {
- return name;
- }
- public char getGender() {
- return gender;
- }
- public List<String> getInventory() {
- return inventory;
- }
- }
- public class Main {
- public static void main(String[] args) {
- Character coolKid = new Character("Cool Kid", 'f',
- Arrays.asList("just", "testing"));
- System.out.println(coolKid.getInventory());
- // returns [just, testing]
- }
- }
- return Collections.unmodifiableList(inventory);
Add Comment
Please, Sign In to add comment