I'm trying to figure out how to produce the following code:

• Add person
• Print all people (alphabetically by name)
• Print all people of a designated type (faculty, staff, students)
• Print a faculty member and the students who are studying the program taught by the faculty member
• Print staff members who are designated as advisors and the list of assigned students grouped by program of study.
• Remove a person. Do not remove a faculty member or advisor who has still students who have not yet graduated.
• Retrieve a person

I have not been able to find any help with this project can anyone point me in a good direction?

Recommended Answers

All 4 Replies

import java.util.TreeMap;
import java.util.Iterator;

public class Directory
{
    private TreeMap<String, Persons> schoolDirectory;
    private int numberInDirectory;
  
    
    
    public Directory()
    {       
        schoolDirectory = new TreeMap<String, Persons>();
       
    }
                      
    public void addPerson(Persons newPersons)
    {
        schoolDirectory.put(Persons.getKey(), newPersons);
        numberInDirectory++;
    }
       
    public void addPerson(Staff newStaff)
    {
        schoolDirectory.put(newStaff.getKey(), newStaff);
        numberInDirectory++;
    }
             
    public int getNumber()
     {
        return numberInDirectory;
     }


public class Persons
{
    private String firstName, lastName, emailAddress, phoneNumber, ID;
    
    public Persons(String firstName, String lastName, String emailAddress, String phoneNumber, String ID)
    {
        this.firstName = firstName;
        this.lastName = lastName;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.ID = ID;
    }
   
    
    public String getKey(Persons newPersons)
    {
        return lastName + firstName;
    }
}

OK, that's a good start! So what exactly are you stuck on?

(Please post your code in code tags next time - it's much more readable)

I have all of the following information for all sections of this project but no idea how to perform the previously stated steps needed. here is all the code.

public class Persons
{
    private String firstName, lastName, emailAddress, phoneNumber, ID;
    
    public Persons(String firstName, String lastName, String emailAddress, String phoneNumber, String ID)
    {
        this.firstName = firstName;
        this.lastName = lastName;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.ID = ID;
    }
    
    public String getKey()
    {
        return lastName + firstName;
    }
}
/**
 * 
 */
public class Student extends Persons
{
    private String AssignedAdvisor;
    private String YearOfEntry;
    private String Program;
    private String GradDate;
   

        public Student(String firstName, String lastName, String emailAddress, String phoneNumber, String ID, String advisor, String year, String degree, String date)
    
        {
            super(firstName, lastName, emailAddress, phoneNumber, ID);
            AssignedAdvisor = advisor;
            YearOfEntry = year;
            Program = degree;
            GradDate = date;    
    }
}
/**
 * 
 */
public class Staff extends Persons
{
    private String OfficeNumber;
    private String JobTitle;
    
        public Staff(String firstName, String lastName, String emailAddress, String phoneNumber, String ID, String office, String position)
        {
        super(firstName, lastName, emailAddress, phoneNumber, ID);
        OfficeNumber = office;
        JobTitle = position;
    }
    
}
/**
 * 
 */
  public class Faculty extends Persons
  {
      private String RoomNumber;
      private String EmployeeStatus;
      private String ProgramOfInstruction;
      
        public Faculty(String firstName, String lastName, String emailAddress, String phoneNumber, String ID, String room, String status, String instruction)
        {
            super(firstName, lastName, emailAddress, phoneNumber, ID);
            RoomNumber = room;
            EmployeeStatus = status;
            ProgramOfInstruction = instruction;
    }
}
import java.util.TreeMap;

public class Directory
{
    private TreeMap<String, Persons> schoolDirectory;
    private int numberInDirectory;
    
    
    
    public Directory()
    {       
        schoolDirectory = new TreeMap<String, Persons>();
        numberInDirectory=0;
    }
    
    public void addPerson(Student newStudent)
    {
        schoolDirectory.put(newStudent.getKey(), newStudent);
        numberInDirectory++;
    }
   
    public void allPeople(Staff newStaff)
    {
        schoolDirectory.put(newStaff.getKey(), newStaff);
        numberInDirectory++;
    }
             
    public int getNumber()
     {
        return numberInDirectory;
     }
    
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.