/
lemal
/
test
Обзор
Документация
Войти
/
lemal
/
test
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/org/example/RandCard.java
27 строк
728 B
malenno
First steps: card, random card generator
22 авг 2024, 11:31
22 авг 2024, 11:31
f984b58
Код
Авторство
О чём код?
package org.example; import org.example.Card; import java.lang.Math; public class RandCard { private static final int largestVal = 11; private static final int largestType = 4; //i assume this will give 4 options public static int RandGenVal(){ return (int) ((Math.random() * (largestVal - 1)) + 1); } public static String RandGenType(){ int choice = (int) ((Math.random() * (largestType - 1)) + 1); String[] faces = {"clubs", "diamonds", "hearts", "spades"}; return faces[choice]; } public static Card get(){ Card c = new Card(); c.setVal(RandGenVal()); //generate val c.setType(RandGenType()); //generate type return c; } }