我正在编写一个程序来评估4张扑克牌的整数值(数字1-13),并显示一个等于24的解决方案.我有一个很大的if语句,我已经为此编写并且意识到它只是太多的解决方案来添加它们.我正在寻找有关如何将其浓缩为更优化版本的建议.代码运行正常,没有错误,这是我的整个代码:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.scene.image.ImageView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicReference;
import java.util.*;
public class Main extends Application {
private Card card1;
private Card card2;
private Card card3;
private Card card4;
private int a;
private int b;
private int c;
private int d;
private int e=0;
private int f=0;
boolean par=false;
@Override
public void start(Stage primaryStage) …Run Code Online (Sandbox Code Playgroud)