Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an application that models courses, students, and faculty members in a uni

ID: 3889889 • Letter: W

Question

Write an application that models courses, students, and faculty members in a university.

General Directions

Use proper Java naming conventions.

From now on it will be assumed that each class you create will have private instance variables and any necessary getters and setters. I will no longer explictly ask you to create these.

Be sure to implement toString() for each class.

You may JOptionPane for the I/O in this lab. Either way, think carefully about how to organize the input/output for this lab *before* you begin coding.

Address Class

An address has a street number, street name, city, state or province, and country.

Person Class

A Person has a name and an Address (represented by an object of class Address, not a String). Note that the subclasses of Person inherit the fields and methods of Person. You may need to override some of the methods in the subclasses.

Student Class

Student is a subclass of Person. In addition to the data inherited from Person, a student has CIN and a course schedule represented by an ArrayList of Courses (objects of class Course). You must provide ways for a Student to add and drop an existing Course.

FacultyMember Class

FacultyMember is also subclass of Person. A FacultyMember has an employee id number and a teaching schedule, which is an ArrayList of Courses. Provide a way to assign a FacultyMember to teach an existing Course and for a Faculty member to find a class in the list and drop it.

Course Class

A course has a course identifier (eg, EE-132) and a number of units (int).

University Class

Write a University class that maintains lists of Students, Courses, and FacultyMembers and has an instance method containing a menu that provides ways to list them and to create them and add them to the list. Provide ways to delete Students and FacultyMembers and for Students and FacultyMembers to add and delete Courses from their course schedules. However, you do not need to provide a way to delete a Course from the list of Courses. Do not create a new Course when a Student adds or when a faculty member is assigned to teach; let the user choose a Course from the list.

Driver Class

Write a simple Driver class that instantiates a University and calls the correct method to get the menu.

Explanation / Answer

public class Address {

private String streetNo;

private String streetName;

private String city;

private String state;

private String postalCode;

public String getStreetNo() {

return streetNo;

}

public void setStreetNo(String streetNo) {

this.streetNo = streetNo;

}

public String getStreetName() {

return streetName;

}

public void setStreetName(String streetName) {

this.streetName = streetName;

}

public String getCity() {

return city;

}

public void setCity(String city) {

this.city = city;

}

public String getState() {

return state;

}

public void setState(String state) {

this.state = state;

}

public String getPostalCode() {

return postalCode;

}

public void setPostalCode(String postalCode) {

this.postalCode = postalCode;

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("Address [streetNo=");

builder.append(streetNo);

builder.append(", streetName=");

builder.append(streetName);

builder.append(", city=");

builder.append(city);

builder.append(", state=");

builder.append(state);

builder.append(", postalCode=");

builder.append(postalCode);

builder.append("]");

return builder.toString();

}

}

public class Person {

private String name;

private String phoneNo;

private Address address;

private String email;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getPhoneNo() {

return phoneNo;

}

public void setPhoneNo(String phoneNo) {

this.phoneNo = phoneNo;

}

public Address getAddress() {

return address;

}

public void setAddress(Address address) {

this.address = address;

}

public String getEmail() {

return email;

}

public void setEmail(String email) {

this.email = email;

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("Person [name=");

builder.append(name);

builder.append(", phoneNo=");

builder.append(phoneNo);

builder.append(", address=");

builder.append(address);

builder.append(", email=");

builder.append(email);

builder.append("]");

return builder.toString();

}

}

import java.util.ArrayList;

public class Student extends Person{

private String cin;

private String classStatus;

private ArrayList<Course> courseSchedule;

public String getCin() {

return cin;

}

public void setCin(String cin) {

this.cin = cin;

}

public String getClassStatus() {

return classStatus;

}

public void setClassStatus(String classStatus) {

this.classStatus = classStatus;

}

public ArrayList<Course> getCourseSchedule() {

return courseSchedule;

}

public void setCourseSchedule(ArrayList<Course> courseSchedule) {

this.courseSchedule = courseSchedule;

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("Student [name=");

builder.append(super.getName());

builder.append(", phoneNo=");

builder.append(super.getPhoneNo());

builder.append(", address=");

builder.append(super.getAddress());

builder.append(", email=");

builder.append(super.getEmail());

builder.append(", cin=");

builder.append(cin);

builder.append(", classStatus=");

builder.append(classStatus);

builder.append(", courseSchedule=");

builder.append(courseSchedule);

builder.append("]");

return builder.toString();

}

}

public class Course {

private String courseIdentifier;

private String courseTitle;

private String term;

private FacultyMember instructor;

public String getCourseIdentifier() {

return courseIdentifier;

}

public void setCourseIdentifier(String courseIdentifier) {

this.courseIdentifier = courseIdentifier;

}

public String getCourseTitle() {

return courseTitle;

}

public void setCourseTitle(String courseTitle) {

this.courseTitle = courseTitle;

}

public String getTerm() {

return term;

}

public void setTerm(String term) {

this.term = term;

}

public FacultyMember getInstructor() {

return instructor;

}

public void setInstructor(FacultyMember instructor) {

this.instructor = instructor;

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("Course [courseIdentifier=");

builder.append(courseIdentifier);

builder.append(", courseTitle=");

builder.append(courseTitle);

builder.append(", term=");

builder.append(term);

builder.append(", instructor=");

builder.append(instructor);

builder.append("]");

return builder.toString();

}

}

import java.util.ArrayList;

public class FacultyMember extends Person{

private String employeeId;

private ArrayList<Course> teachingSchedule;

public String getEmployeeId() {

return employeeId;

}

public void setEmployeeId(String employeeId) {

this.employeeId = employeeId;

}

public ArrayList<Course> getTeachingSchedule() {

return teachingSchedule;

}

public void setTeachingSchedule(ArrayList<Course> teachingSchedule) {

this.teachingSchedule = teachingSchedule;

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("FacultyMember [name=");

builder.append(super.getName());

builder.append(", phoneNo=");

builder.append(super.getPhoneNo());

builder.append(", address=");

builder.append(super.getAddress());

builder.append(", email=");

builder.append(super.getEmail());

builder.append(", employeeId=");

builder.append(employeeId);

builder.append(", teachingSchedule=");

builder.append(teachingSchedule);

builder.append("]");

return builder.toString();

}

}

import java.util.ArrayList;

public class DriverClass {

static ArrayList<Student> studentsList = new ArrayList<Student>();

static ArrayList<FacultyMember> facultyList = new ArrayList<FacultyMember>();

static ArrayList<Course> coursesList = new ArrayList<Course>();

static ArrayList<Address> addresses = new ArrayList<Address>();

public DriverClass(){

Address add1 = new Address();

add1.setStreetNo("1");

add1.setStreetName("1st Street");

add1.setCity("WallCity");

add1.setState("WallState");

add1.setPostalCode("372647");

Address add2 = new Address();

add2.setStreetNo("2");

add2.setStreetName("2nd Street");

add2.setCity("WallCity");

add2.setState("WallState");

add2.setPostalCode("372647");

Address add3 = new Address();

add3.setStreetNo("3");

add3.setStreetName("3rd Street");

add3.setCity("WallCity");

add3.setState("WallState");

add3.setPostalCode("372647");

Address add4 = new Address();

add4.setStreetNo("4");

add4.setStreetName("4th Street");

add4.setCity("WallCity");

add4.setState("WallState");

add4.setPostalCode("372647");

Student john = new Student();

john.setName("John");

john.setAddress(add1);

john.setEmail("email@domain.com");

john.setPhoneNo("9439530");

john.setCin("1");

john.setClassStatus("freshman");

Student dan = new Student();

dan.setName("Dan");

dan.setAddress(add2);

dan.setEmail("email@domain.com");

dan.setPhoneNo("9439730");

dan.setCin("2");

dan.setClassStatus("sophomore");

Student paul = new Student();

paul.setName("Paul");

paul.setAddress(add3);

paul.setEmail("email@domain.com");

paul.setPhoneNo("9439630");

paul.setCin("3");

paul.setClassStatus("senior");

FacultyMember alex = new FacultyMember();

alex.setName("Alex");

alex.setAddress(add1);

alex.setEmail("email@domain.com");

alex.setPhoneNo("6639530");

alex.setEmployeeId("123");

FacultyMember mike = new FacultyMember();

mike.setName("Mike");

mike.setAddress(add4);

mike.setEmail("email@domain.com");

mike.setPhoneNo("9349500");

mike.setEmployeeId("124");

Course algebra = new Course();

algebra.setCourseIdentifier("AG-023");

algebra.setCourseTitle("Algebra");

algebra.setTerm("Basic concepts");

algebra.setInstructor(mike);

Course calculas = new Course();

algebra.setCourseIdentifier("CA-023");

algebra.setCourseTitle("Calculas");

algebra.setTerm("Basic concepts");

algebra.setInstructor(alex);

ArrayList<Course> algebraCourses = new ArrayList<Course>();

algebraCourses.add(algebra);

ArrayList<Course> calculasCourses = new ArrayList<Course>();

calculasCourses.add(calculas);

alex.setTeachingSchedule(calculasCourses);

mike.setTeachingSchedule(algebraCourses);

john.setCourseSchedule(algebraCourses);

dan.setCourseSchedule(calculasCourses);

paul.setCourseSchedule(calculasCourses);

studentsList.add(paul);

studentsList.add(dan);

studentsList.add(john);

facultyList.add(mike);

facultyList.add(alex);

coursesList.add(algebra);

coursesList.add(calculas);

addresses.add(add1);

addresses.add(add2);

addresses.add(add3);

addresses.add(add4);

}

public void listStudents(){

for(Student stu: studentsList){

System.out.println(stu);

}

}

public void addStudent(Student student){

studentsList.add(student);

System.out.println("Student added");

}

public void deleteStudent(Student student){

if(studentsList.contains(student)){

studentsList.remove(student);

System.out.println("Student deleted");

}

else{

System.out.println("Student not on list");

}

}

public static void main(String[] args) {

DriverClass driver = new DriverClass();

driver.listStudents();

Address add5 = new Address();

add5.setStreetNo("5");

add5.setStreetName("5th Street");

add5.setCity("WallCity");

add5.setState("WallState");

add5.setPostalCode("372647");

Student joe = new Student();

joe.setName("Joe");

joe.setAddress(add5);

joe.setEmail("email@domain.com");

joe.setPhoneNo("9439530");

joe.setCin("4");

joe.setClassStatus("senoir");

joe.setCourseSchedule(coursesList);

driver.addStudent(joe);

driver.deleteStudent(joe);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote