Superclass/Subclass
MetaData:
Creating Object
Keyword Final
Superclass
Subclass
Integer
String
public class Main {
public static void main(String[] args) {
Users u = new Users(1, "Mike","Williams");
System.out.println(u.fname);
ULogin ul = new ULogin("mw34",null, 1, "Mike","Williams");
System.out.println(ul.username);
//System.out.println(getUsername);
}
}
OUTPUT:
Mike
mw34
public class Users {
public final Integer uid;
public final String fname;
public final String lname;
Users(Integer uid, String fname, String lname){
this.uid=uid;
this.fname=fname;
this.lname=lname;
}
}
import java.util.Date;
public class UsersInfo extends Users {
public final double height;
public final double weight;
public final double eyecolor;
public final int age;
public final Date bdate;
UsersInfo(Integer uid, String fname, String lname, double height, double weight, int age, Date bdate) {
super(uid, fname, lname);
//TODO Auto-generated constructor stub
}
public double getUserInfo()
{
return height;
return weight;
return eyecolor;
return age;
}
}
public class ULogin extends Users {
public final String username;
public final String pword;
ULogin(String username, String pword, int uid, String fname, String lname){
super(uid, fname, lname);
this.username=username;
this.pword=pword;
}
public String getUsername()
{
return username;
}
}
public class UsersLocation extends Users {
UsersLocation(Integer uid, String fname, String lname) {
super(uid, fname, lname);
//TODO Auto-generated constructor stub
}
}