ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 9.00

Josephs singleton pattern

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 

 

  • applying assertion
  • exceptions
  • data formatting
  • localization

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.}

Answers

(11)
Status NEW Posted 22 May 2017 07:05 AM My Price 9.00

-----------

Not Rated(0)