Untitled
unknown
plain_text
9 months ago
1.9 kB
4
Indexable
class User {
private int level= 1;
private int canSeeProfiles = 1;
private int canBuyThings= 1;
private int canSellThings= 1;
public User(int level, int canSeeProfiles, int canBuyThings, int canSellThings) {
this.level = level;
this.canSeeProfiles = canSeeProfiles;
this.canBuyThings = canBuyThings;
this.canSellThings = canSellThings;
}
public int getLevel() {
return level;
}
public int getCanSeeProfiles() {
return canSeeProfiles;
}
public int getCanBuyThings() {
return canBuyThings;
}
public int getCanSellThings() {
return canSellThings;
}
}
class NormalUser extends User {
public NormalUser(){
super(1,1,1,1);
}
}
class SilverUser extends User {
public SilverUser() {
super(2, 2, 1, 1);
}
}
class GoldUser extends SilverUser {
public GoldUser() {
super();
}
@Override
public int getCanBuyThings() {
return 4;
}
}
public class Main {
public static void main(String[] args) {
GoldUser gu = new GoldUser();
System.out.println("Can Sell Things: " + gu.getCanSellThings());
System.out.println("Can Buy Things: " + gu.getCanBuyThings());
System.out.println("LeveL: " + gu.getLevel());
NormalUser nu = new NormalUser();
System.out.println("Level: " + nu.getLevel());
System.out.println("Can Sell Things: " + nu.getCanSellThings());
System.out.println("Can Buy Things: " + nu.getCanBuyThings());
SilverUser su = new SilverUser();
System.out.println("Level: " + su.getLevel());
System.out.println("Can Buy Things: " + su.getCanBuyThings());
System.out.println("Can Sell Things: " + su.getCanSellThings());
}
}
Editor is loading...
Leave a Comment