Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Help On Java Homework (DUE TONIGHT!!!)

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help On Java Homework (DUE TONIGHT!!!)

    Problem: (The Person, Sruden, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. A faculty member has office hours and a rank. A staff member has a title. Overridde the toString method in each class to display the class name and the person's name.
    Draw the UML diagram for classes. Implement the classes. Write a tes program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() methods

    I am having trouble overriding the toString method in each class, Can any one give me any clarfication? (And If you see any other problems i might have, please help, thanks) And am I using the Superclass correctly?

    public class Person {
     
        private String name, address, phone, email;
     
        public Person(){
        }
     
        public Person(String name, String address, String phone, String email){
            this.name = name;
            this.address = address;
            this.phone = phone;
            this.email = email;
        }
     
        public String getName(){
            return name;
        }
     
        public void setName(String name){
            this.name = name;
        }
     
         public String getAddress(){
            return address;
        }
     
        public void setAddress(String address){
            this.address = address;
        }
     
        public String getPhone(){
            return phone;
        }
     
        public void setPhone(String phone){
            this.phone = phone;
        }
     
        public String getEmail(){
            return phone;
        }
     
        public void setEmail(String email){
            this.email = email;
        }
     
        @Override
        public String toString(){
            return getClass().getName() + "\n" + name;
        }
    }

    public class Student extends Person{
     
        private final String CLASS_STATUS;
     
        public Student(String name, String address, String phone, String email,String CLASS_STATUS){
            super(name, address, phone, email);
            this.CLASS_STATUS =CLASS_STATUS;
        }
     
        public String getClassStatus(){
            return CLASS_STATUS;
        }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help On Java Homework (DUE TONIGHT!!!)

    I am having trouble overriding the toString method in each class
    Can you explain what the problem is?

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Help On Java Homework (DUE TONIGHT!!!)

    Please read this: http://www.javaprogrammingforums.com...e-posting.html

    As well as the link in my signature on asking questions the smart way.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Help On Java Homework (DUE TONIGHT!!!)

    Also, please don't spam post multiple copies of the same question. I've deleted your duplicate thread.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. The Following User Says Thank You to KevinWorkman For This Useful Post:

    JavaPF (September 14th, 2011)

Similar Threads

  1. Help With Java Homework: Set Operations
    By kilroyjr in forum Java Theory & Questions
    Replies: 10
    Last Post: April 1st, 2011, 09:41 AM
  2. Null Pointer Exception--need help tonight!
    By anarchy2465 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 13th, 2010, 08:26 AM
  3. Help for java homework
    By Dark_Shadow in forum Object Oriented Programming
    Replies: 6
    Last Post: December 7th, 2009, 04:08 AM
  4. MORE java homework help.
    By TommyFiz in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: October 13th, 2009, 07:15 PM