-
Notifications
You must be signed in to change notification settings - Fork 0
Description
- Improve naming, that's extremely bad naming:
QuizApp/com/myapp/AdminPage.java
Lines 11 to 29 in 3f2084f
JLabel questionText = new JLabel("Question text"); JTextField question = new JTextField(); JLabel optionText = new JLabel("options"); JTextField option1 = new JTextField(); JTextField option2 = new JTextField(); JTextField option3 = new JTextField(); JTextField option4 = new JTextField(); JButton add = new JButton("Add question"); JButton clear = new JButton("Clear all questions"); JButton done = new JButton("Done"); JRadioButton r1 = new JRadioButton(); JRadioButton r2 = new JRadioButton(); JRadioButton r3 = new JRadioButton(); JRadioButton r4 = new JRadioButton(); ButtonGroup bg = new ButtonGroup(); JLabel empty = new JLabel(""); ArrayList<String> questions = new ArrayList<>(); ArrayList<String[]> options = new ArrayList<>(); ArrayList<String> correctAns = new ArrayList<>(); - Magic numbers:
QuizApp/com/myapp/AdminPage.java
Line 34 in 3f2084f
super.setBounds(500, 300, 600, 500); QuizApp/com/myapp/AdminPage.java
Line 38 in 3f2084f
container.setLayout(new GridLayout(8, 2, 2, 10)); QuizApp/com/myapp/LoginForm.java
Line 28 in 3f2084f
container.setLayout(new GridLayout(6, 1, 2, 10)); QuizApp/com/myapp/LoginForm.java
Line 48 in 3f2084f
container.setLayout(new GridLayout(6, 1, 2, 10)); QuizApp/com/myapp/UserPage.java
Line 25 in 3f2084f
super.setBounds(500, 300, 600, 500); QuizApp/com/myapp/UserPage.java
Line 29 in 3f2084f
container.setLayout(new GridLayout(8, 1, 2, 10));
- Code duplication:
QuizApp/com/myapp/UserPage.java
Lines 100 to 126 in 3f2084f
if(e.getSource() == option1) { if(option1.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option2) { if(option2.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option3) { if(option3.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option4) { if(option4.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); QuizApp/com/myapp/UserPage.java
Lines 100 to 126 in 3f2084f
if(e.getSource() == option1) { if(option1.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option2) { if(option2.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option3) { if(option3.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion(); } if(e.getSource() == option4) { if(option4.getText().equals(correctAns.get(index))) { correctGuesses++; } index++; nextQuestion();
- No interesting code, add something except bolerplates