Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code so far. Please help! public class Student extends person { private List takenCourses; private float gpa; public class course1 { private

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

This is my code so far. Please help!

public class Student extends person {

private List takenCourses;

private float gpa;

public class course1 {

private String courseID;

private String courseName;

private course1 prerequisties;

private Instructor instructor;

private Year offeredYear;

public course1(String title, Instructor instructor, Year offeredYear) {

generateID();

this.courseName = title;

this.prerequisties = null;

this.instructor = instructor;

this.offeredYear = offeredYear;

}

public course1(String title, Instructor instructor, Year offeredYear, course1 prerequisties) {

generateID();

this.courseName = title;

this.prerequisties = prerequisties;

this.instructor = instructor;

this.offeredYear = offeredYear;

}

public void generateID() {

UUID uuid = UUID.randomUUID();

String id = uuid.toString().replace("-", "").substring(0, 10);

this.courseID = id;

}

public String getCourseId() {

return this.courseID;

}

public void setCourseName(String title) {

this.courseName = title;

}

public String getCourseName() {

return this.courseName;

}

public String toString() {

return courseName + courseID;

}

public course1 getPrerequisites() {

return this.prerequisties;

}

public Instructor getInstructor() {

return this.instructor;

}

public Year getOfferedYear() {

return this.offeredYear;

}

public static void add(course1 newcourse) {

}

public Student() {

super();

this.takenCourses = new LinkedList();

this.gpa = (float) 0.0;

}

public Student(String pId, String fName, String lName, Date birthDate, Date startDate) {

super();

this.takenCourses = new LinkedList();

this.gpa = (float) 0.0;

}

public void addCourse(course1 courseName) {

course1.add(courseName);

}

public void dropCourse() {

}

public void setgpa(float gpa) {

this.gpa = (float) 0.00;

}

public float getgpa() {

return this.gpa;

}

@Override

public void printInfo() {

System.out.println("ID: " + this.getPID());

System.out.println("First Name: " + this.getFName());

System.out.println("Last Name: " + this.getLName());

System.out.println("Birth Date: " + this.getBD());

System.out.println("Start Date: " + this.getSD());

System.out.println("GPA: " + this.getgpa());

}

public class Instructor extends person {

private float teachingRate;

private List taughtCourses;

public Instructor() {

super();

DecimalFormat numberFormat = new DecimalFormat("#.00");

Random rn = new Random();

float a = 2 + rn.nextInt(3) + rn.nextFloat();

float aa = Float.parseFloat(numberFormat.format(a));

this.teachingRate = aa;

this.taughtCourses = new LinkedList();

}

public void setTeachingRate(){

}

public float getTeachingRate() {

return this.teachingRate;

}

public void setTaughtCourses(List t) {

this.taughtCourses.addAll(t);

}

public List getTaughtCourses(){

return this.taughtCourses;

}

}

public abstract class person {

private String pId;

private String fName;

private String lName;

private Date birthDate;

private Date startDate;

protected void Person(String pId, String fName, String lName, Date birthDate, Date startDate) {

this.pId = pId;

this.fName = fName;

this.lName = lName;

this.birthDate = (Date)birthDate.clone();

this.startDate = (Date)startDate.clone();

}

public String getPID() {

return this.pId;

}

public String getFName() {

return this.fName;

}

public String getLName() {

return this.lName;

}

public Date getBD() {

return this.birthDate;

}

public Date getSD() {

return this.startDate;

}

public void setPID(String pID) {

this.pId = pID;

}

public void setFName(String fName) {

this.fName = fName;

}

public void setLName(String lName) {

this.lName = lName;

}

public void setBD(Date BD) {

this.birthDate = BD;

}

public void setSD(Date SD) {

this.startDate = SD;

}

public void printInfo() {

System.out.println("ID: " + this.getPID());

System.out.println("First Name: " + this.getFName());

System.out.println("Last Name: " + this.getLName());

System.out.println("Birth Date: "+ this.getBD());

System.out.println("Start Date: "+ this.getSD());

}

}

public class Main {

public static void main(String []args) {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd");

Date birthDate = new GregorianCalendar(1990,Calendar.FEBRUARY, 11).getTime();

Date startDate = new GregorianCalendar(2014,Calendar.MARCH, 11).getTime();

course1 c1 = new course1("Algebra", null, Year.parse("2016"));

course1 c2 = new course1("Biology", null, Year.parse("2016"));

course1 c3 = new course1("Chemistry", null, Year.parse("2016"));

course1 c4 = new course1("Computer Science", null, Year.parse("2016"));

List myCourses = new LinkedList();

myCourses.add(c1);

myCourses.add(c2);

myCourses.add(c3);

myCourses.add(c4);

System.out.println(Arrays.toString(myCourses.toArray()));

person s1 = new Student("02343454", "Adam", "Smith",birthDate,startDate);

s1.printInfo();

}

}

CSC 1302 sks (All steps must be submit in icollege due on March 28th 2018) Continued from lab 8 Follow the steps below to improve the enrollment system we created before. 5. Back to Course 1. How to solve the problem of printing junk characters?! 6. Back to Student Check vour addCourse) method by adding some courses to a student's list. Can vou add one course multiple times? Does it make any sense? 1. Modify the method addCourse)so that it avoids adding repetitive courses 2. 3. Check your code and see if it works 4. Something is wrong, isn't it? 7. Back to Course 1. What else should we change If we want to modify the method addCourse() in Student to avoid adding repetitive courses? 8. Back to Student Add a method dropCourseOthat lets students to remove a course from their list. 1. 2. Check your code and see if it works. (Do you see the magic?!) CSC 1302 sks (All steps must be submit in icollege due on March 28th 2018) Continued from lab 8 Follow the steps below to improve the enrollment system we created before. 5. Back to Course 1. How to solve the problem of printing junk characters?! 6. Back to Student Check vour addCourse) method by adding some courses to a student's list. Can vou add one course multiple times? Does it make any sense? 1. Modify the method addCourse)so that it avoids adding repetitive courses 2. 3. Check your code and see if it works 4. Something is wrong, isn't it? 7. Back to Course 1. What else should we change If we want to modify the method addCourse() in Student to avoid adding repetitive courses? 8. Back to Student Add a method dropCourseOthat lets students to remove a course from their list. 1. 2. Check your code and see if it works. (Do you see the magic?!)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions