d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Singleton Class?
Add Reply New Topic New Poll
Member
Posts: 29,350
Joined: Mar 27 2008
Gold: 504.69
Nov 1 2015 10:22am
One of my assignments asks us to implement a menu using a singleton class and I am kind of confused on what it is asking.

Prof said a singleton class is just a class with one purpose.

So is he asking us to create a new singleton class that has one method, that's a menu, and return some data type to use in a switch case from my main method? Or is there something more to it.

I have a feeling this is probably not what you would use a singleton class for in the real world, this is all just for education.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 1 2015 10:50am
Quote
Prof said a singleton class is just a class with one purpose.

No. Either he misspoke or you misunderstood. Singletons mean only one object can exist at a time. So you need a private constructor. there are different patterns you can follow (lazy loading, eager loading, etc).

can you post the exact words of the assignment? i'm not clear what this menu is. just some kind of "choose option 1, 2, or 3" in the console?

This post was edited by carteblanche on Nov 1 2015 10:53am
Member
Posts: 29,350
Joined: Mar 27 2008
Gold: 504.69
Nov 1 2015 04:22pm
Quote (carteblanche @ Nov 1 2015 12:50pm)
No. Either he misspoke or you misunderstood. Singletons mean only one object can exist at a time. So you need a private constructor. there are different patterns you can follow (lazy loading, eager loading, etc).

can you post the exact words of the assignment? i'm not clear what this menu is. just some kind of "choose option 1, 2, or 3" in the console?


http://www.printupon.ca/humber/course/CENG212/Labs/proj05_CarDealer.htm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 1 2015 05:00pm
Quote (ROM @ Nov 1 2015 05:22pm)


okay, what you said sounds about right then. it will display the menu and get user input. you might want to handle invalid input in there, too.
Member
Posts: 29,350
Joined: Mar 27 2008
Gold: 504.69
Nov 2 2015 07:42am
Quote (carteblanche @ Nov 1 2015 07:00pm)
okay, what you said sounds about right then. it will display the menu and get user input. you might want to handle invalid input in there, too.


Thank you once agian
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll