a public class Address { private String _city; private String _state; private String _streetName; // New private int _streetNumber; //

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

the following code is centered around data collection, filtering, and using the Singleton pattern in Java, which is all part of a mockup "student information management system", with its purpose being making mockup new student accounts. I've been having issues using the software “dbeaver” for making java projects. Please organize the below code into an executable project “simulation.student” and given step by step instruction as to how this was done

Address.java

public class Address {
private String _city;
private String _state;
private String _streetName; // New
private int _streetNumber; // New
private int _apartmentNumber; // New

public Address(String city, String state, int zip, String streetName, int streetNumber, int apartmentNumber) {
setCity(city);
setState(state);
setZip(zip);
setStreetName(streetName);
setStreetNumber(streetNumber);
setApartmentNumber(apartmentNumber);
}

public String getCity() {
return _city;
}

public void setCity(String city) {
_city = city;
}

public String getState() {
return _state;
}

public void setState(String state) {
_state = state;
}

public int getZip() {
return _zip;
}

public void setZip(int zip) {
_zip = zip;
}

public String getStreetName() {
return _streetName;
}

public void setStreetName(String streetName) {
_streetName = streetName;
}

public int getStreetNumber() {
return _streetNumber;
}

public void setStreetNumber(int streetNumber) {
_streetNumber = streetNumber;
}

public int getApartmentNumber() {
return _apartmentNumber;
}

public void setApartmentNumber(int apartmentNumber) {
_apartmentNumber = apartmentNumber;
}
}

 

Student.java

 

public abstract class Student {
private long Id;
private String _lastName, _firstName;
protected Address _stuAddress;

protected double tuition;
protected StudentClassification eStudentClass;

public Student(String firstName, String lastName, StudentClassification eStudent, Address stuAddress) {
setId();
if ((!firstName.equals("")) && (firstName.matches("^[-a-zA-Z\\s]*$"))) {
setFirstName(firstName);
} else {
setFirstName("INVALID FIRST NAME");
}
setLastName(lastName);
setClassification(eStudent);
_stuAddress = stuAddress;
}

private void setId() {
Id = StudentIdGenerator.getNextId();
}

public long getId() {
return Id;
}

public String getLastName() {
return _lastName;
}

public void setLastName(String pName) {
_lastName = pName;
}

public String getFirstName() {
return _firstName;
}

public void setFirstName(String pName) {
_firstName = pName;
}

public double getTuition() {
return tuition;
}

public StudentClassification getClassification() {
return eStudentClass;
}

public abstract void setTuition();

@Override
public String toString() {
StringBuilder studentInfo = new StringBuilder("Name: " + getFirstName() + " " + getLastName() + "\n");
studentInfo.append("ID: " + getId() + " Tuition: " + getTuition() + "\n");
studentInfo.append("Address: " + _stuAddress.getCity() + ", " + _stuAddress.getState());
studentInfo.append(" " + _stuAddress.getZip());
studentInfo.append(" " + _stuAddress.getStreetName() + ", " + _stuAddress.getStreetNumber());
studentInfo.append(", Apt " + _stuAddress.getApartmentNumber());
return studentInfo.toString();
}
}

StudentDemo3.java

import java.util.ArrayList;

public class StudentDemo3 {
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<>();
StringBuilder studentOutput = new StringBuilder("");

// Use the setStartingID() method in 'StudentIdGenerator' Singleton class to start at 500
StudentIdGenerator.setStartingID(500);

students.add(new UndergraduateStudent("Harry Muggle", "Potter", StudentClassification.FRESHMAN,
new Address("Atlanta", "Georgia", 30305, "Main St", 123, 101)));
students.add(new UndergraduateStudent("Diana-Wonder-Woman", "Prince", StudentClassification.JUNIOR,
new Address("Washington D.C.", "District of Columbia", 30318, "Broadway Ave", 456, 202)));

// Add two GraduateStudent objects to the 'students' collection (ArrayList)
students.add(new GraduateStudent("John", "Doe", StudentClassification.MASTERS,
new Address("New York", "New York", 10001, "5th Ave", 789, 303)));
students.add(new GraduateStudent("Jane", "Smith", StudentClassification.DOCTORATE,
new Address("Los Angeles", "California", 90001, "Sunset Blvd", 987, 505)));

// Loop to print student information
for (Student s : students) {
studentOutput.append("\n-----------------------------\n").append(s.toString());
if (s instanceof UndergraduateStudent) {
studentOutput.append("\nUndergraduate student of status: ").append(s.getClassification().toString());
} else if (s instanceof GraduateStudent) {
studentOutput.append("\nGraduate student of status: ").append(s.getClassification().toString());
}
System.out.println(studentOutput.toString() + "\n");
studentOutput.setLength(0);
}
}
}

 


 please run the code such that it has the appropriate expected outcome of

 


-----------------------------
Name: Diana-Wonder-Woman Prince
ID: 501 Tuition: 4000.0
Address: Washington D.C., District of Columbia 30318
Undergraduate student of status: JUNIOR

Graduate Student.java
public class Graduate Student extends Student {
public static final double GRAD_TUITION = 6000;
public Graduate Student(String fName, String IName, StudentClassification eStudent, Address stuAddress) {
super(fName, IName, eStudent, stuAddress);
set Tuition();
}
@Override
public void setTuition() {
tuition = GRAD_TUITION;
}
}
Transcribed Image Text:Graduate Student.java public class Graduate Student extends Student { public static final double GRAD_TUITION = 6000; public Graduate Student(String fName, String IName, StudentClassification eStudent, Address stuAddress) { super(fName, IName, eStudent, stuAddress); set Tuition(); } @Override public void setTuition() { tuition = GRAD_TUITION; } }
Undergraduate Student.java
public class Undergraduate Student extends Student {
public static final double UNDERGRAD_TUITION = 4000;
public Undergraduate Student(String fName, String IName, StudentClassification eStudent, Address stuAddress) {
super(fName, IName, eStudent, stuAddress);
set Tuition();
}
@Override
public void setTuition() {
tuition = UNDERGRAD_TUITION;
}
}
Transcribed Image Text:Undergraduate Student.java public class Undergraduate Student extends Student { public static final double UNDERGRAD_TUITION = 4000; public Undergraduate Student(String fName, String IName, StudentClassification eStudent, Address stuAddress) { super(fName, IName, eStudent, stuAddress); set Tuition(); } @Override public void setTuition() { tuition = UNDERGRAD_TUITION; } }
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education