Directory.javaDirectory.java is a program whose purpose is to check membership within a group. The three basic operations of Directory.java areenter – adds a name, id pair to the groupremove – removes a name from the group and its corresponding idlookup – determines if a name is in the group. If the name is in the group, then the id field is set with the user's id and the message field indicates that the name is in the group. Otherwise, the message field indicates the name is not in the group.Your job is to fill in the missing code in Directory.java. The comments, method and variable names should give you enough context to be able to fill in the blanks. You only need to fill in where there are blanks.Directory.javaimport javax.swing.*;import java.awt.*;import java.awt.event.*;import java.util.*;/* * Created on Feb 28, 2004 *//** * @author Jam Jenkins * * This class simulates a directory of students and ids */public class Directory extends JApplet implements ActionListener {private JFrame frame;private JButton removeButton, enterButton, lookupButton, quitButton;private JLabel nameLabel, idLabel, messageLabel;private JTextField nameField, idField, messageField;private HashMap members;public Directory(){super();makeComponents();layoutComponents();members=new HashMap();}Directory.java/** initialize all of the component instance * variables and add this as an * ActionListener to all JButtons*/private void makeComponents(){frame=new JFrame("Access Control");removeButton=new JButton("remove");removeButton.addActionListener(this); ; ; ; ; ; ;nameLabel=new JLabel("Name:"); ; ;nameField=new JTextField(20); ; ;}Directory.java/**put all components in the JFrame's container*/private void layoutComponents(){Container container=frame.getContentPane();container.setLayout( );container.add( );container.add( );frame.pack();}/** * @return the Jpanel with all the JLabels and JTextFields */private JPanel getMiddlePanel(){ ;panel.add(nameLabel);panel.add(nameField);panel.add(idLabel);panel.add(idField);panel.add(messageLabel);panel.add(messageField);return panel;}Directory.java/** * @return the JPanel with all the JButtons */private JPanel getButtonPanel(){JPanel panel=new JPanel(new GridLayout(1, 4));panel.add( );panel.add( );panel.add( );panel.add( );return panel;}Directory.java/** * removes a user to members by getting input * from nameField. If the user existed, the * messageField indicates the user was removed, * otherwise the messageField indicates that no * such user was a member */private void remove(){String name=nameField.getText();if(members.containsKey(name)){members.remove(name);messageField.setText(name+" removed from members.");}else{messageField.setText(name+" is not a member.");}}/** * adds a user to members by getting input * from nameField and idField */private void enter(){String name=nameField.getText();String id=idField.getText();members.put(name, id);messageField.setText(name+" added as a member.");nameField.setText("");idField.setText("");}/** * looks up a user by name and outputs the * user id in the idField (if found) and * indicates whether the user is or is not * a member in the messageField */private void lookup(){String name=nameField.getText();if(members.containsKey(name)){String id=(String)members.get(name);idField.setText(id);messageField.setText(name+" is a member.");}else{messageField.setText(name+" is not a member.");}}/** * quits the program */private void quit(){frame.setVisible(false);frame.dispose();System.exit(0);}Directory.javapublic void actionPerformed(ActionEvent e) {Object cause=e.getSource();if(cause== ){//removes a user and corresponding idremove();}else if(cause==enterButton){//adds a user and corresponding id ;}else if( ){//looks up a user and corresponding id ;}else if( ){//quits the program ;}}Directory.javapublic void init(){frame.setVisible(true);}public static void main(String[] args) {Directory directory=new Directory();directory.init();}}TopTenYour mission is to fill in the missing code in TopTen.java, TopTenPanel.java, and TopTenTest.java. The comments, method and variable names should give you enough context to be able to fill in the blanks. You only need to fill in where there are blanks. A description of each class is given to the right.TopTen.java – this class keeps the scores in an array of doubles sorted least to greatest. It extends Observable and is the model.TopTenPanel – this class displays the scores in a Jpanel which it extends. This class is the view.TopTenTest – this class is the controller and it connects the model (TopTen) and the view (TopTenPanel) in order to test them.TopTen.javaimport java.util.*;/** * @author Jam Jenkins * * This class keeps a list of the top ten scores. */public class TopTen extends Observable{/**scores is ordered in ascending order*/double[] scores; public TopTen(){//initialize score to hold 10 doubles ;}TopTen.java/** * add a score if it ranks in the top ten * @param s the score to add */public void registerScore(double s){//remember that score is sorted least to greatestif( )//score is better than the lowest score{scores[0]=s;Arrays.sort(scores);setChanged();notifyObservers();}}TopTen.java /** * get a score from the top ten * @param rank the position in the top ten list * with 1 being the highest and 10 being the lowest * @return the score */public double getScore(int rank){//score is sorted least to greatest//think about how the rank relates to the index in the arrayreturn ;}}TicTacToe.javaimport java.awt.*;import javax.swing.*;import java.util.*;/** * @author Jam Jenkins * * Displays the scores in a JPanel */public class TopTenPanel extends JPanelimplements Observer{/**JLabels with the numbers 1-10*/ private JLabel[] ranks;/**the numeric scores for the top ten*/private JLabel[] scores; public TopTenPanel(){super();makeComponents();layoutComponents();}TopTenPanel.javaprivate void makeComponents(){ranks=new JLabel[10];scores=new JLabel[10];for(int i=0; ; i++){ranks[i]=new JLabel(""+(i+1));scores[i]=new JLabel("none");}} private void layoutComponents(){setLayout(new GridLayout(10, 2));for( ;
View Full Document