Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Mason Cudlitz
- */
- public class DataBaseValue {
- Calendar calendar;
- Date createdDate;
- private final String name;
- public DataBaseValue(String name) {
- this.name = name;
- calendar = Calendar.getInstance();
- createdDate = calendar.getTime();
- }
- public String getName() {
- return name;
- }
- //overridden
- public String getInfo() {
- return "I AM ERROR";
- }
- public Date getCreatedDate() {
- return createdDate;
- }
- }
- class International extends DataBaseValue {
- //Fields
- private final int id;
- private final Date dateOfBirth;
- private final String homeAddress;
- private final String localAddress;
- private final String phoneNumber;
- private int age;
- private final Visa visa;
- //input
- Scanner input = new Scanner(System.in);
- International(String name, Date dateOfBirth, String homeAddress,
- String localAddress, String phoneNumber, Visa visa) {
- super(name);
- this.id = name.hashCode();
- this.dateOfBirth = dateOfBirth;
- setAge(dateOfBirth);
- this.homeAddress = homeAddress;
- this.localAddress = localAddress;
- this.phoneNumber = phoneNumber;
- this.visa = visa;
- }
- void setAge(Date dateOfBirth) {
- age = (int) (TimeUnit.DAYS.convert(StaticDataFunctions.deltaTime(dateOfBirth, getCreatedDate()), TimeUnit.MILLISECONDS) / 365);
- }
- //Accessors
- public Visa getVisa() {
- return visa;
- }
- public int getAge() {
- return age;
- }
- //Builds a return card for the person when retrieved from the Database
- String formatInfo(String[] extraParameters) {
- String[] infoLines = new String[]{
- "Name: " + this.getName(),
- "Date of Birth: " + dateOfBirth.getMonth() + "/" + dateOfBirth.getDay() + "/" + dateOfBirth.getYear(),
- "Age: " + age + " years",
- "Home Address: " + homeAddress,
- "Local Address: " + localAddress,
- "Visa class: " + visa.getVisaType(),
- "Visa permissions: " + visa.getVisaPermissions(),
- "Expiry date: " + visa.getExpiryDate() + " (expires in " + visa.getExpiryDays() + " days)"
- };
- if (extraParameters != null) {
- infoLines = (String[]) StaticDataFunctions.concatenateArrays(infoLines, extraParameters);
- }
- int longestLine = 0;
- for (String l : infoLines) {
- if (l.length() > longestLine) {
- longestLine = l.length() + 2;
- }
- }
- StringBuilder formatBuilder = new StringBuilder();
- for (int y = 0; y < infoLines.length + 2; y++) {
- formatBuilder.append('\n');
- for (int x = 0; x < longestLine; x++) {
- //Draws box
- if (y == 0 || y == infoLines.length + 1 || x == longestLine - 1) {
- formatBuilder.append('/');
- } else if (x == 0) {
- if (y > 0 && y < infoLines.length + 1) {
- formatBuilder.append('/').append(infoLines[y - 1]);
- x += infoLines[y - 1].length();
- //x -= infoLines[y - 1].length();
- }
- } else {
- formatBuilder.append(" ");
- }
- }
- }
- return formatBuilder.toString();
- }
- //This will be overriden
- }
- class Intellectual extends International {
- List<Class> classes = new ArrayList();
- public Intellectual(String name, Date dateOfBirth, String homeAddress, String localAddress,
- String phoneNumber, Visa visa) {
- super(name, dateOfBirth, homeAddress, localAddress, phoneNumber, visa);
- }
- public String addClass(Class newClass) {
- //Overridden
- return "Err";
- }
- public String removeClass(Class removedClass) {
- //Overridden
- return "Err";
- }
- public boolean hasClass(Class checkedClass){
- return classes.contains(checkedClass);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement