CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: JAVA errors

  1. #1
    Join Date
    Nov 2020
    Location
    Michigan
    Posts
    1

    Question JAVA errors

    Hello, I'm getting a few errors in my code can anyone help thanks.




    Player.java:10: error: invalid method declaration; return type required

    displayFileContents("roster1.txt");

    Player.java:10: error: illegal start of type
    displayFileContents("roster1.txt");
    ^
    Player.java:11: error: invalid method declaration; return type required
    displayFileContents("roster2.txt");
    ^
    Player.java:11: error: illegal start of type
    displayFileContents("roster2.txt");
    ^
    4 errors

    >

    Code:
    public class Player {
    
        private String name = "";
        private double attackStat = 0.0;
        private double blockStat = 0.0;
        
    
       public static Roster openRosterFile() throws IOException;
       
           displayFileContents("roster1.txt");
           displayFileContents("roster2.txt");
         
    
           
    
        
      public Player(String initName, double initAttackStat, double initBlockStat){ 
        
           name = intName;
            attackStat = AttackStat;
            blockStat = BlockStat;
      }
        
        public String getName()
        {
            return name;
        }
        
        public double getAttackStat()
        {
            return attackStat;
        }
        
        public double getBlockStat()
        {
            return blockStat;
        }
        
        public void setName(String s)
        {
            name = s;
        }
        
        public void setAttackStat(double x)
        {
            attackStat = x;
        }
        
        public void setBlockStat(double x)
        {
            blockStat = x;
        }
        
        public void printPlayerInfo()
        {
            System.out.println(name + "(attack =" + " " + attackStat + " " + "block =" + " " + blockStat);
            
        }
            
        
        
        public static void main(String args[]);
        
        
    
    public void addPlayer(String playersName, double initAttackStat, double initBlockStat) {
       
    }
    
      public int countPlayers() {
         
        return Player;
      }
    
      public void getPlayerByName() {
         
         
    
      }
    
      public void PrintTopAttackers () {
    
      }
    
      public double PrintAllBlockers() {
    
      }
    
      public void printAllPlayers(double newBlockStat) {
    
      
    
      
      }
    }
    Last edited by Arjay; December 1st, 2020 at 01:39 AM. Reason: Added code tags

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,461

    Re: JAVA errors

    There are so many errors in that code I'm not sure where to begin.

  3. #3
    Join Date
    Feb 2017
    Posts
    599

    Re: JAVA errors

    Quote Originally Posted by PopPopooz View Post
    can anyone help thanks.
    Start with a minimal program that works. In this case just a main method that prints "Hello world". Then add code, little by little in incremental steps making sure it works after each step. So you start with a working program, make sure the program works all the time during development and you end up with a finished program that works. Follow this simple rule and you will become a Java guru in no time.
    Last edited by wolle; December 1st, 2020 at 05:03 AM.

  4. #4
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,867

    Re: JAVA errors

    public static Roster openRosterFile() throws IOException;
    Look at how the other methods are declared to see how it needs to be done.
    Norm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)