TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
yuriy thebest
NA
7
0
initialize class array "correctly"
Oct 30 2011 6:38 AM
Right, I have a simple class for any upgrade the player can get, including an array containing the cost of each upgrade level, so my initialization looks like:
myUpgrade.description="some description here";
myUpgrade.maxUpgrade=10;
myUpgrade.upgradeCostArray[0]=100;
myUpgrade.upgradeCostArray[1]=230;
myUpgrade.upgradeCostArray[2]=233;
.
.
myUpgrade.upgradeCostArray[9]=12233;
As you can see this doesn't look too good- I have a predefined size 10 int array in my class, AND if any value in the array that is below maxUpgrade is not initialized it will only show up during runtime. Is there a cleaner way of doing this, perhaps somehow with a constructor?
Reply
Answers (
4
)
Get name of class property?
Automating JSP website using C# HttpWebRequest