Question: Write a singleton class called Register, that keeps a record of the names of people registered on a system. Persons are only allowed to register

Write a singleton class called Register, that keeps a record of the names of people registered on a system. Persons are only allowed to register once and all names should be managed by a single resource. An outline of the code is given. Complete the constructor and methods getRegister and register.

class Register{ private static Register reg = null; private String[] data; private int size; private Register(){ // Complete constructor code } public static Register getRegister(){ // complete getRegister code } public boolean register(String name){ // complete register code } public int size(){return size;} public Object clone() throws CloneNotSupportedException{ throw new CloneNotSupportedException(); } private boolean search(String n){ boolean found = false; for(int j = 0; j < size && !found; j++) if(data[j].equals(n)) found = true; return found; } }

language java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!