gpt4 book ai didi

java - Java 变量太多?

转载 作者:行者123 更新时间:2023-12-02 06:03:03 25 4
gpt4 key购买 nike

<分区>

我对 Java 还是很陌生,但我个人觉得我的代码很草率,变量太多了。我知道我可以将它们隐藏在方法或类中,但我听说将它们放在一个单独的类中是不好的做法,而且它们中的大多数都不是静态的。谁能给我一些提示?提前致谢!

public static float c = .2f; //cube dimensions
private float separation = 4.0f*c;
private float angle = 0f; //set to 0
private float rotate = 1.0f;
private float h_height = 1.0f;
private float h_width = 1.0f;
private float h_length = 1.0f;
private float b_height = 1.5f;
private float b_width = .5f;
private float b_length = 1.0f;
private float a_height = 1.5f;
private float a_width = .5f;
private float a_length = .5f;
private float l_height = 1.5f;
private float l_width = .5f;
private float l_length = .5f;
private float h_x_s = 0.0f*c;
private float h_y_s = 5.0f*c;
private float h_z_s = 0.0f*c;
private float h_x;
private float h_y;
private float h_z;
private float b_x_s = 0.0f*c;
private float b_y_s = 2.5f*c;
private float b_z_s = 0.0f*c;
private float b_x;
private float b_y;
private float b_z;
private float a_x_s = 1.5f*c;
private float a_y_s = 2.5f*c;
private float a_z_s = .0f*c;
private float a_x;
private float a_y;
private float a_z;
private float l_x_s = .5f*c;
private float l_y_s = -.5f*c;
private float l_z_s = 0.0f*c;
private float l_x;
private float l_y;
private float l_z;
private float a_rotate = 0f;
private float a_speed = .6f;
private float l_rotate = 0;
private float l_speed = .6f;
private double a_c;
private double l_c;
private double a_s;
private double l_s;
private float max_a = 30f; //angle
private float max_l = 30f; //angle
private boolean a_forward;
private boolean l_forward;
private float move_z = 0; //set to 0
private float speed_z = .01f*separation;
private float max_z = 2*separation;
private boolean forward_z;

附言注释实际上并不是变量的用途,只是在调试时提醒我。此外,我的变量名可能会遭到专业开发人员的强烈反对,但这是我可以轻松跟踪的内容。就像我之前说过的,这些变量中的大多数都在积极变化,并为此在多种方法中使用,但有一些我不在,我可以躲起来。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com