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 October 1st, 2006, 09:57 PM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
Array of type class?

Ok, I'm in the final stage of finishing up an application. I have been requested to create a class, that has one constructor with one parameter: an array of type Row, where Row is a class on my application.

So far I've got
Code:
//Player.java
package nim; 
   public class Player implements NimPlayer{
   
      private Row [] rows;
      public ComputerNimPlayer(Row[] row){//will add some stuff here}   
      
   }

Does anyone know if that's the right format?
Rigth now the error I'm getting is
nim.Player is not abstract and does not override abstract method setBoard(nim.Row[]) in nim.NimPlayer

Reply With Quote
  #2  
Old October 2nd, 2006, 09:22 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Yes, the code you've presented seems syntax-correct...
What does your NimPlayer object look like?

When you implement an interface, you need to include all methods... even if you just want them empty.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old October 2nd, 2006, 02:05 PM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
The only stuff on NimPlayer is
Code:
public Move selectMove();
    public void setBoard (Row [] rows);

So am I supposed to include setBoard? I'm sorry I have to ask and not try it myself, but I'm still busy on the details of the other parts, but it would be great if you could help me figure out the syntax before I do some coding on Player.java

BTW i noticed I was asked for a constructor, so I changed
Code:
 public ComputerNimPlayer(Row[] row){//will add some stuff here}

to
Code:
public Player(Row[] row){//will add some stuff here}

Reply With Quote
  #4  
Old October 3rd, 2006, 03:57 AM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
Well, the syntax is still not working. Here is what I've got so far:
Code:
package nim;
import java.util.Random;

    public class ComputerNimPlayer implements NimPlayer{
      Random random = new Random();
      private Row [] rows;
      public ComputerNimPlayer(Row[] row){
          rows = new Row[1+random.nextInt(17)];
      selectMove();
      setBoard(rows);
      }   
        public Move selectMove(){ 
        int howmany = 1 + (new Random().nextInt(21));        
        return howmany; 
        }
        
      public void setBoard(Row[] row){
      }
    }

Code:
// * NimPlayer.java

package nim;
public interface NimPlayer {
    public Move selectMove();
    public void setBoard (Row [] rows);
}

and the error I get is
Quote:
found : int
required: nim.Move
return howmany;
1 error


I want private Row [] rows; to be the only data member for the class with a single parameter constructor that sets rows.
So far I think the constructor and the select move method are OK, but that single error I'm getting it's driving me nuts.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Array of type class?


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 3 hosted by Hostway
Stay green...Green IT