Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2005, 12:04 PM   #1
rselge
Newbie
 
Join Date: Feb 2005
Posts: 2
Rep Power: 0 rselge is on a distinguished road
simple homework

I have porblem with homework..someone who know how to write it pleas help



Write a class that can be created only in a single instance and only by some specific method.

For example this should work:

SingleInstance pInst = SingleInstance.getInstance();
pInst.someMethod();

And this shouldn't:

SingleInstance oneInstance = new SingleInstance();
oneInstance.someMethod();

The second call to getInstance() method should return the pointer to the already existing object and do not create a new one.

Hints: private, public, static
rselge is offline   Reply With Quote
Old Feb 16th, 2005, 4:21 PM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
have you tried any code yet. People around here don't do homework for people. Post your code, then people will help you.

We aren't a home work service.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Feb 16th, 2005, 5:06 PM   #3
rselge
Newbie
 
Join Date: Feb 2005
Posts: 2
Rep Power: 0 rselge is on a distinguished road
sry but i have no idea how to start or to do it
rselge is offline   Reply With Quote
Old Feb 16th, 2005, 5:45 PM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
i am pretty sure that your teracher showed you how to write a class. If you still don't know, try searching google for some answers.


This is one of many that i found on about five minutes of browsing.
http://java.sun.com/docs/books/tutor...classdecl.html
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!

Last edited by Pizentios; Mar 9th, 2005 at 11:16 AM.
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC