-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJLabelQuestions.java
More file actions
45 lines (41 loc) · 1.42 KB
/
Copy pathJLabelQuestions.java
File metadata and controls
45 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class JLabelQuestions extends Question{//inherits from question
private String question, answer;
private int questionNum;
public JLabelQuestions(int points, int questionNum) {
super(points);//calling question constructor
this.questionNum = questionNum;
assignQuestion();
}
public void assignQuestion() {
if(questionNum == 0) {
question = "Fill in the blank: A JLabel is a _______ that simply displays text or images, or both text and images and can be added to a JPanel.";
answer = "Component";
}else if(questionNum==1) {
question = "True or False: A JLabel by default is not transparent.";
answer = "False";
}else if(questionNum==2) {
question = "Fill in the blank: Given the JLabel object, “label”, invoke a method to return the text displayed in the label\r\n"
+ "\r\n"
+ "label._______();\r\n"
+ "";
answer = "getText()";
}else if(questionNum==3) {
question = "True or False: A JLabel can only display text.";
answer = "False";
}else if(questionNum==4) {
question = "Fill in the blank: Given the JLabel object, “label”, invoke a method to set the text displayed in the label\r\n"
+ "\r\n"
+ "label._______(“I love computer science!”);\r\n"
+ "";
answer = "setText";
}
}
public String getAnswer() {
return answer;
}
public String getQuestion() {
return question;
}
public void setBackOfCard() {
}
}