Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Player {
- // Variables
- String name;
- String skin;
- String backpack;
- int level;
- boolean hasBattlePass;
- ArrayList <Weapon> weapons;
- // Constructors
- Player(){
- name = "Bot Clarence";
- skin = "Default";
- backpack = "Red Cape - Default Backpack";
- level = 1;
- hasBattlePass = false;
- weapons = new ArrayList <Weapon> ();
- }
- Player(String name, String skin, String backpack, int level, boolean hasBattlePass, ArrayList <Weapon> weapons){
- this.name = name;
- this.skin = skin;
- this.backpack = backpack;
- this.level = level;
- this.hasBattlePass = hasBattlePass;
- this.weapons = weapons;
- }
- // Methods
- void showStatus() {
- System.out.println("Name: " + name);
- System.out.println("Skin: " + skin);
- System.out.println("Backpack: " + backpack);
- System.out.println("Level: " + level);
- System.out.println("HasBattlePass: " + hasBattlePass);
- System.out.println("Weapons' List: ");
- if(weapons.size() > 0) {
- for(int i=0; i<weapons.size(); i++) {
- System.out.println("Slot " + (i+1) + ": " + weapons.get(i).color + " " + weapons.get(i).name);
- }
- }
- else {
- System.out.println("No weapons yet.");
- }
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Weapon a = new Weapon("Tactical Shotgun", "blue");
- Weapon b = new Weapon();
- Weapon c = new Weapon("Sniper", "mple");
- ArrayList <Weapon> weapons = new ArrayList <Weapon> ();
- weapons.add(a);
- weapons.add(b);
- weapons.add(c);
- System.out.println();
- Player player1 = new Player();
- player1.showStatus();
- System.out.println();
- Player player2 = new Player("Thomas", "Flamingo King", "Red Cape", 40, true, weapons);
- player2.showStatus();
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement