This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuizDisplayer { | |
private static void displayQuestion(Question question) { | |
int optionChosen = JOptionPane.showOptionDialog(null, question.getQuestion(), "Please Select", | |
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, question.getAnswerOptions(), | |
question.getAnswerOptions()[0]); | |
String answer = question.getAnswerOptions()[optionChosen]; | |
boolean correct = answer.equals(question.getCorrectAnswer()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void displayQuestion(Question question) { | |
int optionChosen = JOptionPane.showOptionDialog(null, question.getQuestion(), "Please Select", | |
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, question.getAnswerOptions(), | |
question.getAnswerOptions()[0]); | |
String answer = question.getAnswerOptions()[optionChosen]; | |
boolean correct = answer.equals(question.getCorrectAnswer()); | |
// this is what we'll output if the question is correct or not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Question { | |
private String question; | |
private String correctAnswer; | |
private String[] answerOptions; | |
public Question(String question, String correctAnswer, String[] answerOptions) { | |
this.question = question; | |
this.correctAnswer = correctAnswer; | |
this.answerOptions = answerOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.anemortalid.essex.whatson.scrape; | |
import java.awt.Graphics; | |
import java.awt.image.BufferedImage; | |
import java.io.InputStream; | |
import java.net.URL; | |
import javax.imageio.ImageIO; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.anemortalid.essex.whatson.scrape; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
import java.util.List; | |
public class WhileLoop { | |
public static void main(String[] args) { | |
// assume this is the data from the file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Steve { | |
String input; | |
String[] steve = { "you", "can", "start", "by" }; | |
JFrame frame; | |
JTextField textField; | |
public Steve() { | |
frame = new JFrame(); | |
textField = new JTextField(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Animal { | |
private String name; | |
public Animal(String name) { | |
this.name = name; | |
} | |
public void setName(String name) { | |
this.name = name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringReplaceStuff { | |
public static void main(String[] args) { | |
String testString = "Hello World!"; | |
// replace o with 0, replaceAll takes a string pattern to replace | |
String osReplaced = testString.replaceAll("o", "0"); | |
System.out.println("Without O = " + osReplaced); | |
// if we want to add to our replacement, we need to do it in different |