Any Java programmers out there? - VeggieBoards
Forum Jump: 
 
Thread Tools
#1 Old 12-15-2008, 07:40 PM
Veggie Regular
 
heidiny77's Avatar
 
Join Date: Mar 2007
Posts: 507
I have my final assignment due on Thursday and I need to build a constructor that takes an array as a parameter but I'm having some trouble initializing my objects with the constructor I've built. So I'm not sure if my constructor is incorrect or if I'm not initializing/filling my array correctly.



I can speak with my Prof about it tomorrow but I was hoping to get a little farther on the project before then.



So if anyone has ideas, let me know and we can get in touch about the code.



Thanks!
heidiny77 is offline  
Sponsored Links
Advertisement
 
#2 Old 12-16-2008, 11:34 AM
Beginner
 
Insomniana's Avatar
 
Join Date: Dec 2008
Posts: 133
Game.java

Array: private String[] name = new String[2];

Constructor: public Game(String[] name) {}

Object creation: Game myGame = new Game(new String[] {"value1", "value2"});



this MAY be it. my boyfriend's not that sure, because he couldnt test it.

just tell me how that worked out, okay? (:
Insomniana is offline  
#3 Old 12-16-2008, 11:41 AM
Veggie Regular
 
heidiny77's Avatar
 
Join Date: Mar 2007
Posts: 507
Quote:
Originally Posted by Insomniana View Post

Game.java

Array: private String[] name = new String[2];

Constructor: public Game(String[] name) {}

Object creation: Game myGame = new Game(new String[] {"value1", "value2"});



this MAY be it. my boyfriend's not that sure, because he couldnt test it.

just tell me how that worked out, okay? (:



I got your PM and just emailed you the code.
heidiny77 is offline  
Sponsored Links
Advertisement
 
#4 Old 12-16-2008, 12:10 PM
Beginner
 
Insomniana's Avatar
 
Join Date: Dec 2008
Posts: 133
Is it ok for you, when I answer you again in an hour?

Because my boyfriend's on his way to me and then I can show him the code. (:
Insomniana is offline  
#5 Old 12-16-2008, 12:11 PM
Veggie Regular
 
heidiny77's Avatar
 
Join Date: Mar 2007
Posts: 507
Quote:
Originally Posted by Insomniana View Post

Is it ok for you, when I answer you again in an hour?

Because my boyfriend's on his way to me and then I can show him the code. (:



That's cool...I appreciate any help he can give and I'm here at work for another 3 hours...then I'm off to school...



Just tell him not to laugh...
heidiny77 is offline  
#6 Old 12-16-2008, 12:18 PM
Beginner
 
Insomniana's Avatar
 
Join Date: Dec 2008
Posts: 133
Oh right, time differences.. it's 2pm in NY, isnt it? here it is 8 pm. ^^
Insomniana is offline  
#7 Old 12-16-2008, 12:20 PM
Veggie Regular
 
heidiny77's Avatar
 
Join Date: Mar 2007
Posts: 507
Quote:
Originally Posted by Insomniana View Post

Oh right, time differences.. it's 2pm in NY, isnt it? here it is 8 pm. ^^



Oh that's funny...yes it is 2:20 p.m. here.
heidiny77 is offline  
#8 Old 12-16-2008, 01:43 PM
Beginner
 
Insomniana's Avatar
 
Join Date: Dec 2008
Posts: 133
here you go: my boyfriend commented the code he edited.

we hope it works. (:

 

heidihoassignment7.zip 1.662109375k . file
Insomniana is offline  
#9 Old 12-16-2008, 02:00 PM
Veggie Regular
 
Melanie's Avatar
 
Join Date: May 2006
Posts: 1,921
I only learn Java toward the end of the year, but I'm glad you got help.
Melanie is offline  
#10 Old 12-16-2008, 07:08 PM
Veggie Regular
 
heidiny77's Avatar
 
Join Date: Mar 2007
Posts: 507
Thank you! I'll take a look and see if it compares to what my teacher said...such a doof! I didn't need to make the array a parameter in the constructor!



Now to complete the rest of the methods...
heidiny77 is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the VeggieBoards forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in


Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may 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
Trackbacks are On
Pingbacks are On
Refbacks are Off