Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 26th, 2007, 09:58 AM
darken4life darken4life is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 130 darken4life User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 28 m 26 sec
Reputation Power: 2
Frustrated java noob

I get a constructor method undefined while I have it defined.



java Code:
Original - java Code
  1. public class GameEntry{
  2.     public int score = 0;
  3.     public void GameEntry(int new_score){
  4.         score = new_score;
  5.     }//constructor
  6.     public void GameEntry(){
  7.         score = 0;
  8.     }//constructor
  9.    
  10.     public void add(int new_score){
  11.         score = new_score;
  12.     }//add
  13.    
  14.     public void print(){
  15.         System.out.println(score);
  16.     }//print
  17.  
  18.     public static void main(String[] args){
  19.         GameEntry score1 = new GameEntry(233);
  20.     }//main
  21.    
  22. }//GameEntry
  23.  

Reply With Quote
  #2  
Old August 27th, 2007, 12:42 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Click here for more information.
 
Join Date: Sep 2005
Posts: 688 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 21 h 2 m 12 sec
Reputation Power: 4
Remove the void return type from your constructors.
I.e., public GameEntry(int new_score). Constructors do not have a return type. If you do give them a return type then they become just normal methods.

Good luck
Comments on this post
Nilpo agrees!
__________________
Current project: roborally

Reply With Quote
  #3  
Old August 27th, 2007, 05:19 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Near Dev Articles Headquarters
Posts: 137 Nilpo User rank is Private First Class (20 - 50 Reputation Level)Nilpo User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1Folding Points: 197832 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 12 h 55 m 14 sec
Reputation Power: 3
Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Also, since you've added a method to set the score, you should make that class-level variable private.
__________________
Click the image if at any point you don't like my decision.

Ask the Windows Guru!


Reply With Quote
  #4  
Old August 27th, 2007, 05:26 AM
darken4life darken4life is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 130 darken4life User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 28 m 26 sec
Reputation Power: 2
Thanks!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Frustrated java noob


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway