実現したいこと
エラーをどうやったら消せるか知りたいです。
ここに実現したいことを箇条書きで書いてください。
前提
ここに質問の内容を詳しく書いてください。
(例)
TypeScriptで●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
エラーメッセージ
----jGRASP exec: javac -g -J-Duser.language=en Fish.java
Fish.java:157: error: illegal start of expression
public void setLength(int e){
^
Fish.java:164: error: ';' expected
e = ranNum.nextDouble(((MAX-MIN)+1)+MIN)/25.4);
^
2 errors
該当のソースコード
Java
ソースコード
import java.util.Random; //The import statement
import java.text.DecimalFormat;
/**
- Fish.java
- @author
- @since 9/11/23
*/
public class Fish {
//pram fish private String name; // Name private String bodycolor; //Body color private String fincolor; // Fin color private String food; // Foof fish will eat private int length; // length in cm private int weight; // weight in kg private double w = 0.0; // private double l = 0.0; // private Random ranNum = new Random(); private DecimalFormat we = newDecimalFormat("0.00"); // private static final double MIN = 1.0; private static final double MAX = 1000.0; // Constructor #1 for fish // Fish's name = a // Fish's bodycolor = b // Fish's fincolor = c // Fish's food = d // Fish's length = e public Fish (String a, String b, String c, String d, String e){ this.name = a; this.bodycolor = b; this.fincolor = c; this.food = d; this.length = e; } // Constructor #2 for fish // Fish's name = a // Fish's bodycolor = b // Fish's fincolor = c // Fish's food = d public Fish (String a, String b, String c, String d){ this.name = a; this.bodycolor = b; this.fiincolor = c; this.length = d; } //override public String toString() { String f = "Fish name: " + this.name + "\nBody color: " + this.bodycolor + "\nFin color: " + this.fincolor + "\nFood: " + this.food + "\nLength:" + this.length + "in" + "\nWeight" + this.weight + "lbs"; return f; }//close toString //return fish name // get fish name public String getName() { return this.name; } /**
*returns fish bodycolor
*get fish bodycolor
*/ public String getBodycolor() { return this.bodycolor; } /**
*returns fish fincolor *get fish fincolor
*/ public String getFinColor(){ return this.finColor; } /**
*returns fish food
*get fish food
*/ public String getFood(){ return this.food; } /**
*returns fish length
*get fish length
*/ public int getLength(){ return this.length; } /**
*returns fish weight
*get fish weight
*/ public int getWeight(){ return this.weight; } // the fish's name //@pram public void setName(String newName){ if (newName.length() > 0){ this.name = newName(); } else { System.out.println("Error"); } } public void setBodyColor(String newBodyColor){ if (newBodyColor.length() > 0){ this.bodycolor = new BodyColor(); } else { System.out.println("Error"); } } public void setFinColor(String newFinColor){ if (newFinColor.length() > 0){ this.fincolor = newFinColor(); } else { System.out.println("Error"); } } public void setFood(String newFood){ if (newFood.length() > 0){ this.food = newFood(); } else { System.out.println("Error"); } } public Fish(){ public void setLength(int e){ if (newLength > 0){ e = newLength / 25.4; this.length = (int) newLength; //Creating an object of Random class Random Length = newLength(); }else{ e = ranNum.nextDouble(((MAX-MIN)+1)+MIN)/25.4); this.length = (int) newLength; } } public void setWeight(){ double x = 0.0001; double y = 0.0; y = (int) (x * (e*e*e)); w = y * 453.6; this.weight = (int) w; }
}// close class
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
0 コメント