Something went wrong. Try again.
Codelabs for major subjects in the BSIT course at STI College Meycauayan. gitlab.com/andreijiroh-dev/labs/studentops-codelab
Something went wrong. Try again.
1.7 kB · 58 lines
Java
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859package dev.andreijiroh.studentops.projects;
/** * Computer Programming 1 - Lab 1 * * Note that since classes are nested, we need to add static instead of individually do * `public static void` on both `Biodata` and `Manager` classes. * * @author Andrei Jiroh Halili (STI College Meycauayan) <halili.459491@meycauayan.sti.edu.ph> * @see https://stackoverflow.com/questions/9560600/what-causes-error-no-enclosing-instance-of-type-foo-is-accessible-and-how-do-i#9560633 */class Comprog2_Lab1 { static class Biodata { String name; int age; String emailUsername;
Biodata(String name, int age, String emailUsername) { this.name = name; this.age = age; this.emailUsername = emailUsername; }
void introduce() { System.out.println("Goodday, I am "+name+", "+age+" years old and my email is "+emailUsername+"@lairland.is-a.dev."); } }
static class Manager { String name; int age; String position; String organization;
Manager (String name, int age, String position, String organization) { this.name = name; this.age = age; this.organization = organization; this.position = position; }
void introduce() { System.out.println("Hi, I am "+name+", "+age+" years old, the "+position+" of "+organization); } }
public static void main(String[] args) { Biodata crew1 = new Biodata("George", 21, "labs.george"); Biodata crew2 = new Biodata("Gina", 23, "labs.gina"); Biodata crew3 = new Biodata("Kevin", 22, "labs.kevin"); Manager hr = new Manager("Gina",37,"HR","ABC Company");
crew1.introduce(); crew2.introduce(); crew3.introduce(); hr.introduce(); }}