The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hello Team we are going to be doing the learning team improvements on Josephs singleton pattern (attached above) We only have to do one improvement which has to be one of the followingÂ
Â
I am trying to insert one of these into the attached program
Â
/** 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.*/package singleton;/**** @author Joseph Santaniello*/import java.util.*;public class Singleton {private static final Singleton INSTANCE = new Singleton();// This is where one instance is stored, the singleton.private Set<String> openLanes;public static Singleton getInstance() {return INSTANCE;//This is where the user can access the instance.}private Singleton() {//This makes it so users can't access the instance anymore without using// getInstance()openLanes = new HashSet<String>();openLanes.add("Lane 1");openLanes.add("Lane 2");openLanes.add("Lane 3");openLanes.add("Lane 4");openLanes.add("Lane 5");openLanes.add("Lane 6");openLanes.add("Lane 7");openLanes.add("Lane 8");}public boolean takenLane(String lane) {return openLanes.remove(lane);}public static void main(String[] args) {// Here is where only one unique runner will be assigned to each lane.runner("Lane 1");runner("Lane 2");runner("Lane 3");runner("Lane 4");runner("Lane 5");runner("Lane 6");runner("Lane 7");runner("Lane 8");}private static void runner(String lane) {Singleton race = Singleton.getInstance();System.out.println(race.takenLane(lane));// This prints the lanes and whether or not each lane is only assigned// one runner.}