Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can not get it to run successfully... /** * * @author Jacob Stedman */ public class Exercise_11 { public static void main(String[] args) { Person

Can not get it to run successfully...

/** * * @author Jacob Stedman */ public class Exercise_11 {

public static void main(String[] args) {

Person Kim = new Person("Kim", "123 Main St, Honolulu", "8085551212", "kim@hpu.edu");

Student Lee = new Student("Lee", "345 Main St., Honolulu", "8085551215", "lee@hpu.edu", "Sophmore");

Employee Joe = new Employee("Joe", "234 Main St, Honolulu", "8085551213", "joe@hpu.edu", "5000", "6/1/17");

Faculty Sue = new Faculty("Sue", "456 Main St., Honolulu", "8085551220", "sue@hpu.edu", "9:00-11:30", "Associate Professor");

Staff Tim = new Staff("Tim", "567 Main St, Honolulu", "8085551225", "bob@hpu.edu", "Administrator");

// Invoke toString of Person, Student, Employee, Faculty and Staff System.out.println(Kim.toString()); System.out.println(Lee.toString()); System.out.println(Joe.toString()); System.out.println(Sue.toString()); System.out.println(Tim.toString()); } }

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */

/** * * @author Jacob */ class Person { protected String name; protected String address; protected String phoneNumber; protected String email; public Person() { this ("Kim", "123 Main St, Honolulu", "8085551212", "kim@hpu.edu"); } public Person(String name, String address, String phoneNumber, String email) { this.name = name; this.address = address; this.phoneNumber = phoneNumber; this.email = email; } public String getName() { return name; } @Override public String toString() { return "Name: " + name + " Address: " + address + " Phone#: " + phoneNumber + " Email address: " + email; } }

/** * * @author Jacob Stedman */ class Employee extends Person { protected String office; protected double salary; protected MyDate dateHired; public Employee(String joe, String _Main_St_Honolulu, String string, String joehpuedu, String string1, String string2) { this("234 Main St Honolulu", 5000,new MyDate()); } public Employee(String office, double salary, MyDate dateHired) { this.office = office; this.salary = salary; this.dateHired = dateHired; }

Employee Joe = new Employee("Joe", "234 Main St, Honolulu", "8085551213", "joe@hpu.edu", "5000", "6/1/17"); public String getOffice() { return office; } @Override public String toString() { return "Office: " + office + " Salary: $" + salary + " Date hired: " + dateHired + " " + super.toString(); } }

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * * @author Jacob Stedman */

public class MyDate { private int year; private int month; private int day;

public MyDate(){ year = 2011; month = 2; day = 15; }

public int GetYear(){ return year; }

public int GetMonth(){ return month; }

public int GetDay(){ return day; }

public void SetYear(int newYear){ year = newYear; }

public void SetMonth(int newMonth){ if(newMonth > 12 || newMonth

} else{ month = newMonth; } }

public void SetDay(int newDay){ day = newDay; }

//string to date converter... private Date convertStringToDate(String stringDate) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");

Date theDate = dateFormat.parse(stringDate);

return theDate; }

//this is compare...it should have two object arguments... public int Compare(MyDate d1, MyDate d2) throws ParseException{ return (convertStringToDate(String.valueOf(d1.GetMonth()).concat("/"+String.valueOf(d1.GetDay())).concat("/"+String.valueOf(d1.GetYear()))). compareTo(convertStringToDate(String.valueOf(d2.GetMonth()).concat("/"+String.valueOf(d2.GetDay())).concat("/"+String.valueOf(d2.GetYear()))))); }

public void Show(MyDate d1, MyDate d2) throws ParseException{ System.out.printf("%d/%d/%d",month,day,year); System.out.println("\t"+Compare(d1, d2)); }

public static void main(String[] args) throws ParseException { MyDate x0 = new MyDate(); //default... MyDate x1 = new MyDate(); MyDate x2 = new MyDate(); MyDate x3 = new MyDate();

x1.SetYear(2011); x1.SetMonth(5); x1.SetDay(20); //... lines deleted

x2.SetYear(2010); x2.SetMonth(8); x2.SetDay(2); //... lines deleted

x3.SetYear(2011); x3.SetMonth(3); x3.SetDay(15); //... lines deleted

System.out.println("LEGEND: 0 - [ = ] 1 - [ > ] -1 - [

x0.Show(x0, x0); //added to show default date...[ temporary ] x1.Show(x1, x0); x2.Show(x2, x1); x3.Show(x3, x2); } }

/** * * @author Jacob Stedman */ class Faculty extends Employee { public static int LECTURER = 1; public static int ASSISTANT_PROFESSOR = 2; public static int ASSCIATE_PROFESSOR = 3; public static int PROFESSOR = 4; protected String officeHours; protected int rank; public Faculty(String sue, String _Main_St_Honolulu, String string, String suehpuedu, String string1, String assoc_Professor) { this ("09:00-11:30" , 1); } public Faculty(String officeHours, int rank) { super("Joe", "234 Main St, Honolulu", "8085551213", "joe@hpu.edu", "5000", "6/1/17"); this.rank = rank; this.officeHours = officeHours; }

public String getRank() { return (rank == 1) ? "Lecturer" : (rank == 2) ? "Assistant Professor " : (3 == rank) ? "Associate Professor " : "Professor "; } @Override public String toString() { return (rank == 1) ? "Lecture " + officeHours + " in " +getOffice() : (rank == 2)? "Assistant Professor" + officeHours + " in" + getOffice() : (rank == 3)? "Associate Professor" + officeHours + " in " + getOffice() : "Professor " + officeHours + " in " + getOffice(); } }

/** * * @author Jacob Stedman */ class Student extends Person { public static int FRESHMAN = 1; public static int SOPHMORE = 2; public static int JUNIOR = 3; public static int SENIOR = 4; protected int status; public Student(String lee, String _Main_St_Honolulu, String string, String leehpuedu, String sophmore) { this(1); } public Student(int status) { this.status = status; }

Student Lee = new Student("Lee", "345 Main St., Honolulu", "8085551215", "lee@hpu.edu", "Sophmore"); @Override public String toString() { return (status == 1) ? getName() + " is a freshman." : (status == 2) ? getName() + " is a sophmore." : (status == 3) ? getName() + " is a junior." : getName() + " is a senior."; } }

image text in transcribed

Staff,java x Exercise 1 XTD Person.java XTL Employee.java x15 Myoatejava x Faalty.java x d Student.java x Source History author Jacob Stedman public class Exercise 11 7 public static void main (String args) Berson Kim new Person Kim 3 Main St Honolulu 8085551212 "kim hpu.edu") 10 Student Lee new Student ("Lee", 345 Main St., Honolulu 8085551215 "lee@hpu.edu", Sophmore 12 13 Employee Joe new Employee Joe 234 Main St Honolulu 8085551213 "joe hpu.edu", 5000 "6/l/17"); 14 15 16 Faculty Sue new Faculty Sue", 456 Main St Honolulu 8085551 "sue hpu.edu", 9:00-11:30 Associate Professor 17 18 Staff Tim new Staff ("Tim", 567 Main. St, Honolulu 8085551 hpu.edu Administrator 51225", 19 20 Invoke toString of Peraon, Student Employee Faculty and Staff o); 21 System out.println (Kim. toString 22 System out.println (Lee.tostring 23 System out.println (Joe toString 24 System out.println (Sue. toString 25 System out.println (Tim. toStri 26 27 Output Exercise. tion in thread "main" j ava lang. StackowerflowError D C: Users Jacoby Data LocalNetBeana B.24executor-snippetsrun.nl:53: Java returned l \Cache BUILD FAILED total tine: 0 seconds

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

Students also viewed these Databases questions

Question

what is Outsourcing Web hosting?

Answered: 1 week ago