Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C3SC-50-Create-OOP-Classes #3

Closed
wants to merge 1 commit into from
Closed

Conversation

JaiCantCode
Copy link
Collaborator

…. Ready for review and preliminary testing.

@JaiCantCode
Copy link
Collaborator Author

The staff and club manager classes can be replaced with one class called guest. The way to differentiate between a staff and club manager should be the use of an enum called Status that will determine whether or not a guest is staff or club manager.

This is the guest class that will replace staff and club manager \/

import java.time.LocalDate;
public class Guest extends Person {

    public long id_number;
    public Status guest_status;
    public String password;

    public Guest(){
        super();
    }
    public Guest(String firstName, String lastName, String emailAddress, LocalDate birthDate, long phoneNumber) {
        super(firstName, lastName, emailAddress, birthDate, phoneNumber);
    }

    public void setIdNumber(long number) {id_number = number;}
    public void setPassword(String p) {password = p;}
    public void setEnum(Status s) {guest_status = s;}
    public boolean setEnum(String s) {
        try{
            guest_status = Status.valueOf(s);
        }catch (Exception e) {
            return false;
        }
        return true;
    }

    public long getIDNumber() {return id_number;}
    public Status getStatus() {return guest_status;}

    public String toString(){
        return guest_status + ": " + getName() + " -> {\n\t"
                + "ID Number: " + id_number + "\n\t"
                + "Email Address: " + email_address + "\n}";
    }
}

This is the enum that will show whether or not the guest is a staff member or a club manager \/

public enum Status {
    STAFF,
    CLUB_MANAGER
}

The database class will not be needed because the way we are going to connect to the database is through the GUI pages.

All of the classes must be in their own java file so that we can all work on them separately.

The visit log for the gym member can be replaced with a singular LocalDate variable that will represent the most recent date that the member had checked in on.

What member class should look like \/

import java.time.LocalDate;

public class Member extends Person {
    
    public long id_number;
    public LocalDate creation_date;
    public LocalDate expiration_date;
    public LocalDate last_checked_in;

    public Member(String firstName, String lastName, String emailAddress, LocalDate birthDate, long phoneNumber) {
        super(firstName, lastName, emailAddress, birthDate, phoneNumber);
        creation_date = LocalDate.now();
    }

    public void setIdNumber(long number) {id_number = number;}
    public void setCreationDate(LocalDate date) {creation_date = date;}
    public void updateLastCheckedIn() {last_checked_in = LocalDate.now();}
    public void updateExpirationDate(LocalDate date) {expiration_date = date;}

    public long getIDNumber() {return id_number;}
    public LocalDate getCreationDate(){return creation_date;}
    public LocalDate getExpirationDate(){return expiration_date;}
    public LocalDate getLastCheckedInDate(){return last_checked_in;}

    public String toString(){
        return "MEMBER: " + getName() + " -> {\n\t"
                + "Id Number: " + id_number + "\n\t"
                + "Membership Created on: " + creation_date.toString() + "\n\t"
                + "Membership Expires on: " + expiration_date.toString() + "\n\t"
                + "Last Checked in on: " + last_checked_in.toString()  + "\n\t"
                + "Email: " + id_number + "\n}";
    }
}

Person class \/

import java.time.LocalDate;

public class Person {
    public String first_name;
    public String last_name;
    public String email_address;
    public LocalDate date_of_birth;
    public long phone_number;

    public Person(){}
    public Person(String firstName, String lastName, String emailAddress, LocalDate birthDate, long phoneNumber) {
        first_name = firstName.toLowerCase();
        last_name = lastName.toLowerCase();
        email_address = emailAddress.toLowerCase();
        date_of_birth = birthDate;
        phone_number = phoneNumber;
    }

    public String getFirstName(){return first_name;}
    public String getLastName(){return last_name;}
    public String getName(){return first_name.toUpperCase().charAt(0)+first_name.substring(1) + " " + last_name.toUpperCase().charAt(0)+last_name.substring(1);}
    public String getEmailAddress(){return email_address;}
    public LocalDate getBirthDate(){return date_of_birth;}
    public long getPhoneNumber(){return phone_number;}

    public String toString(){
        return getName() + " -> {\n\t"
                + date_of_birth.toString() + "\n\t"
                + "Email: " + email_address + "\n\t"
                + "Phone Number" + phone_number + "\n}";
    }
}

@alina-z7 alina-z7 closed this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants