-
November 30th, 2020, 02:57 PM
#1
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
-
December 1st, 2020, 01:43 AM
#2
Re: JAVA errors
There are so many errors in that code I'm not sure where to begin.
-
December 1st, 2020, 03:52 AM
#3
Re: JAVA errors
Originally Posted by PopPopooz
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.
-
December 2nd, 2020, 10:20 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|