I'm currently writing an password solver in java.
I know what static means, but sometimes I'm not able to find the most simple solutions.
I don't want any static variables.
I'm think it is because of the main method in my first class, but I am nit sure.
package Main;
public class Main {
Main() {
new CodeSolver();
}
public static void main(String[] args) {
new Main();
}
}
CodeSolver:
package Main;
import GUI.Frame;
public class CodeSolver {
String codeOld;
String code ;
String[] ID;
public CodeSolver(){
RegisterId();
new Frame(code);
}
public String giveCode(){
return code;
}
public void RegisterId(){
ID = new String[62];
ID[0] = "a"; ID[1] = "b"; ID[2] = "c"; ID[3] = "d"; ID[4] = "e"; ID[5] = "f"; ID[6] = "g"; ID[7] = "h"; ID[8] = "i"; ID[9] = "j"; ID[10] = "k"; ID[11] = "l"; ID[12] = "m"; ID[13] = "n"; ID[14] = "o"; ID[15] = "p";
ID[16] = "q"; ID[17] = "r"; ID[18] = "s"; ID[19] = "t"; ID[20] = "u"; ID[21] = "v"; ID[22] = "w"; ID[23] = "x"; ID[24] = "y"; ID[25] = "z";
ID[26] = "A"; ID[27] = "B"; ID[28] = "C"; ID[29] = "D"; ID[30] = "E"; ID[31] = "F"; ID[32] = "G"; ID[33] = "H"; ID[34] = "I"; ID[35] = "J"; ID[36] = "K"; ID[37] = "L"; ID[38] = "M"; ID[39] = "N"; ID[40] = "O"; ID[41] = "P";
ID[42] = "Q"; ID[43] = "R"; ID[44] = "S"; ID[45] = "T"; ID[46] = "U"; ID[47] = "V"; ID[48] = "W"; ID[49] = "X"; ID[50] = "Y"; ID[51] = "Z";
ID[52] = "0"; ID[53] = "1"; ID[54] = "2"; ID[55] = "3"; ID[56] = "4"; ID[57] = "5"; ID[58] = "6"; ID[59] = "7"; ID[60] = "8"; ID[61] = "9";
}
public void TestLabel(){
for(int i=0; i <= ID.length; i++){
codeOld = code;
code = ID[i];
System.out.println(ID[i]);
}
}
}
Frame:
package GUI;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import Main.CodeSolver;
public class Frame extends JFrame {
private static final long serialVersionUID = 1L;
String code01;
String code;
JPanel panel;
JLabel label;
public Frame(String codeNew){
code = codeNew;
this.setTitle("CodeSolver");
this.setSize(600, 300);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
panel = new JPanel();
panel.setBounds(0, 0, 600, 300);
panel.setBackground(Color.BLACK);
panel.setVisible(true);
label = new JLabel(code);
label.setBounds(0, 0, 600, 300);
label.setForeground(Color.GREEN);
label.setFont(new Font("Helvetica New", Font.PLAIN, 60));
label.setVisible(true);
panel.add(label);
this.add(panel);
}
public void getCode(){
code01 = CodeSolver.giveCode();
}
}