Это то, что я получаю после того, как составляю свой код, но он не придумывает никаких ошибок, когда я на самом деле печатаю свой код. Поэтому, когда я думаю, что все хорошо идти и хорошо запустить, это не работает. Exception in thread "main" java.lang.IllegalArgumentException: No enum constant Size.34.96
at java.base/java.lang.Enum.valueOf(Enum.java:273)
at Size.valueOf(Size.java:5)
at FindAShirt.loadShirt(FindAShirt.java:158)
at FindAShirt.main(FindAShirt.java:22)
Process finished with exit code 1
< /code>
public record Shirt (String productName, long productCodeNumber, int price, String brand, Size size, int minPrice, int maxPrice) {
/**
* constructor to create a Shirt object
*
* @param productName the shirt's name
* @param productCodeNumber the shirt's code number - unique 9-digit number
* @param price the shirt's price
* @param brand the shirt's brand
* @param size the shirt's size
* @param minPrice the users min price they will pay for a shirt
* @param maxPrice the users max price they will pay for a shirt
*/
public Shirt {
}
//getters
/**
* @return the shirt's name
*/
public String productName() {
return productName;
}
/**
* @return the shirt's code number - unique 9-digit number
*/
public long productCodeNumber() {
return productCodeNumber;
}
/**
* @return the shirt's price
*/
public int price() {
return price;
}
/**
* @return the shirt's brand
*/
public String brand() {
return brand;
}
/**
* @return the shirt's size via enum
*/
public Size size() {
return size;
}
//create min and max price setters and getters
/**
* @return a 'dream' shirt's min price
*/
public int minPrice() {
return minPrice;
}
/**
* @return a 'dream' shirt's max price
*/
public int maxPrice() {
return maxPrice;
}
/**
* enum representing the 8 t-shirt sizes that the geek store stocks
*/
enum Size {
XS, S, M, L, XL, XXL, XXXL, XXXXL;
public String toString() {
return switch (this) {
case XS -> "Extra Small";
case S -> "Small";
case M -> "Medium";
case L -> "Large";
case XL -> "Extra Large";
case XXL -> "2XL";
case XXXL -> "3XL";
case XXXXL -> "4XL";
};
}
}
< /code>
They are all sectioned into parts just like I have them in IntelliJ.
Подробнее здесь: https://stackoverflow.com/questions/732 ... nt-compile
Использование кода Intellij Java имеет минимальные ошибки, но не компилируется? ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение