Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Hero {
- private String username;
- private int level;
- public Hero(String username, int level) {
- this.username = username;
- this.level = level;
- }
- public String getUsername() {
- return username;
- }
- public int getLevel() {
- return level;
- }
- @Override
- public String toString() {
- return String.format("Type: %s Username: %s Level: %s",
- this.getClass().getName(),
- this.getUsername(),
- this.getLevel());
- }
- }
- ====================================================================
- public class Elf extends Hero {
- public Elf(String username, int level) {
- super(username, level);
- }
- }
- =====================================================================
- package Inheritance.P03_PlayersAndMonsters.hero;
- public class Wizard extends Hero {
- public Wizard(String username, int level) {
- super(username, level);
- }
- }
- ====================================================================
- package Inheritance.P03_PlayersAndMonsters.hero;
- public class Knight extends Hero {
- public Knight(String username, int level) {
- super(username, level);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement