Home       Goals       Download       Documentation       Support Us       Development       Job Openings       Webstore       Patrons       Contact us / Enlist      

 

Little-T Cross Platform Initiative

We live in a developing world where borders between operating systems and programs are becoming increasingly blurred.

While many of us have a preference for particular operating systems it is clear that the users as such have less interest in the matter and only have an eye for, does a particular application work on my preferred device or won't it work.

For us as developers it means we need to look at different frameworks over which to deliver our product, one such framework that spans multiple platforms is the Java language and for that reason we have chosen to attempt to use it as a vessel to bring our ideas and assistive aids to as many people as possible.

About the program:

Little-T is essentially currently a quiz type program which is supposed to be used to help people relearn language after for instance having suffered a stroke (Aphasia). This can be very useful in bridging the gap between family, friends nursing personnel, doctors etc. and the sufferer during the initial troublesome path to recovery.

Secondly it is intended as a training tool to learn to associate pictures with words or sentences so that a sufferer of ALS/MS can quickly communicate with the surrounding world by being able to select entire sentences associated to images.

These images could be centered around themes that have meaning, like personal hygiene, entertainment, hobbies etc.

For instance a bathtub can encompass the sentence I'd like a bath, the toilet icon, the sentence I'd like to go to the toilet, the icon of a film strip indicates the desire to see a movie, and the bird in the binocular that the user would like to go birdwatching. The only limitation is the imagination of those setting up the program and the users, but to have any effect one needs to recognize which image means what, and hence Little-T is useful for the aforementioned groups as well. The list goes on but you get the picture.

Classes

The program consists of the following classes , each of these classes is described in a subsection of it's own.

The code has to be self documenting as to cut down on the need to maintain a separate document in which to describe the classes.

LearningModeGUI

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;

import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/

public class LearningModeGUI extends javax.swing.JFrame {
	private JPanel jPanel1;
	private JButton settingsButton;
	private JButton repeatButton;
	private JPanel BannerPanel;
	private JPanel logoPanel2;
	private JPanel logoPanel1;
	private JPanel advertisementPanel;
	private JButton jButton1;
	private JButton exitButton;
	private JButton nextButton;
	private JButton previousButton;
	private JButton stopButton;
	private JButton playButton;
	private JPanel navigationButtonPanel1;
	private JTextPane explanationTextPane1;
	private JButton forwardButton1;
	private JButton imageButton1;
	private JButton backwardButton1;
	private JPanel imageTrainingPanel;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				LearningModeGUI inst = new LearningModeGUI();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public LearningModeGUI() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				jPanel1.setBounds(4, 7, 750, 576);
				jPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				jPanel1.setLayout(null);
				{
					imageTrainingPanel = new JPanel();
					jPanel1.add(imageTrainingPanel);
					imageTrainingPanel.setBounds(8, 6, 734, 237);
					imageTrainingPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					imageTrainingPanel.setLayout(null);
					{
						backwardButton1 = new JButton();
						imageTrainingPanel.add(backwardButton1);
						backwardButton1.setText("BBut1");
						backwardButton1.setBounds(3, 3, 63, 227);
					}
					{
						imageButton1 = new JButton();
						imageTrainingPanel.add(imageButton1);
						imageButton1.setText("imageButton1");
						imageButton1.setBounds(71, 5, 228, 222);
					}
					{
						forwardButton1 = new JButton();
						imageTrainingPanel.add(forwardButton1);
						forwardButton1.setText("FBut1");
						forwardButton1.setBounds(304, 3, 66, 227);
					}
					{
						explanationTextPane1 = new JTextPane();
						imageTrainingPanel.add(explanationTextPane1);
						explanationTextPane1.setText("InsertExplanatoryTextStringHere");
						explanationTextPane1.setBounds(375, 3, 353, 221);
					}
				}
				{
					navigationButtonPanel1 = new JPanel();
					jPanel1.add(navigationButtonPanel1);
					navigationButtonPanel1.setBounds(8, 249, 734, 107);
					navigationButtonPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					navigationButtonPanel1.setLayout(null);
					{
						playButton = new JButton();
						navigationButtonPanel1.add(playButton);
						playButton.setText("play");
						playButton.setBounds(8, 13, 75, 80);
						playButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("playButton.actionPerformed, event="+evt);
								/*TODO add your code for playButton.actionPerformed
								contact LearningModeController, which launches thread in LearningMode1
								which pushes pictures, text and sound into the LearningModeGui by passing the 
								relevant information to a series of methods in the the LearningModeController which then 
								passes them om to the relevant LearningModeGUI */
								// PlaySound.main(new playSound(){} );
							    try {
							        String line;
							        Process p = Runtime.getRuntime().exec(
							        "play /home/ep/data/globability/xtrajava_n_more/soundbites_dk/1P368.wav");
							     p.waitFor();
							        System.out.println(p.exitValue());
							      }
							      catch (Exception err) {
							        err.printStackTrace();
								}
							}
						});
					}
					{
						stopButton = new JButton();
						navigationButtonPanel1.add(stopButton);
						stopButton.setText("stop");
						stopButton.setBounds(92, 13, 75, 80);
					}
					{
						previousButton = new JButton();
						navigationButtonPanel1.add(previousButton);
						previousButton.setText("previous");
						previousButton.setBounds(176, 13, 75, 80);
					}
					{
						nextButton = new JButton();
						navigationButtonPanel1.add(nextButton);
						nextButton.setText("next");
						nextButton.setBounds(260, 13, 75, 80);
					}
					{
						repeatButton = new JButton();
						navigationButtonPanel1.add(repeatButton);
						repeatButton.setText("repeat");
						repeatButton.setBounds(344, 13, 75, 80);
					}
					{
						settingsButton = new JButton();
						navigationButtonPanel1.add(settingsButton);
						settingsButton.setText("switch");
						settingsButton.setBounds(509, 13, 75, 80);
						settingsButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("settingsButton.actionPerformed, event="+evt);
								//TODO add your code for settingsButton.actionPerformed
								//TURN ON StartChangeSwitchGUI
								StartChangeSwitchGUI.main(new String[]{});
							}
						});
					}
					{
						exitButton = new JButton();
						
						navigationButtonPanel1.add(exitButton);
						exitButton.setText("exit");
						exitButton.setBounds(650, 13, 75, 80);
						exitButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("exitButton.actionPerformed, event="+evt);
								//TODO add your code for exitButton.actionPerformed
								YesNoToExit.main(new String[]{});
							}
						});
					}
					{
						jButton1 = new JButton();
						navigationButtonPanel1.add(jButton1);
						jButton1.setText("settings");
						jButton1.setBounds(427, 13, 75, 80);
					}
				}
				{
					advertisementPanel = new JPanel();
					jPanel1.add(advertisementPanel);
					advertisementPanel.setBounds(8, 362, 734, 206);
					advertisementPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					advertisementPanel.setLayout(null);
					{
						logoPanel1 = new JPanel();
						//Here we add an image to our interface				
						String path = "//home/ep/data/globability/xtrajava_n_more/little-t/ffcbox.png";
						/*The above path should be changed to be fed by a method accessible by a controller, 
						 * this way the images	can be altered from time to time without changing the 
						 * interface program */
						JLabel label = new JLabel(new ImageIcon(path));
						label.setHorizontalAlignment(JLabel.CENTER);
						logoPanel1.add(label);
						label.setBounds(6, 7, 163, 162);
						label.setPreferredSize(new java.awt.Dimension(180, 178));
						advertisementPanel.add(logoPanel1);
						logoPanel1.setBounds(3, 7, 187, 192);
						logoPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					}
					{
						logoPanel2 = new JPanel();
						//Here we add an image to our interface				
						String path = "//home/ep/data/globability/xtrajava_n_more/little-t/ffcbox.png";
						/*The above path should be changed to be fed by a method accessible by a controller, 
						 * this way the images	can be altered from time to time without changing the 
						 * interface program */
						JLabel label = new JLabel(new ImageIcon(path));
						label.setHorizontalAlignment(JLabel.CENTER);
						logoPanel2.add(label);
						label.setBounds(6, 7, 163, 162);
						label.setPreferredSize(new java.awt.Dimension(180, 178));
						advertisementPanel.add(logoPanel2);
						logoPanel2.setBounds(7, 7, 203, 192);
						logoPanel2.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
						advertisementPanel.add(logoPanel2);
						logoPanel2.setBounds(542, 7, 189, 192);
						logoPanel2.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					}
					{
						BannerPanel = new JPanel();
						//Here we add an image to our interface				
						String path = "//home/ep/data/globability/xtrajava_n_more/little-t/banbox.png";
						/*The above path should be changed to be fed by a method accessible by a controller, 
						 * this way the images	can be altered from time to time without changing the 
						 * interface program */
						JLabel label = new JLabel(new ImageIcon(path));
						label.setHorizontalAlignment(JLabel.CENTER);
						BannerPanel.add(label);
						label.setBounds(3, 3, 327, 168);
						
						advertisementPanel.add(BannerPanel);
						BannerPanel.setBounds(194, 7, 343, 192);
						BannerPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					}
				}
			}
			pack();
			setSize(767, 618);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

QuizGUI1

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*
*This GUI is intended for creating a flashcard based quiz, further iterations
*need to be implemented creating an abstract model for creating GUI's so that the GUI can be built entirely based on
*a plain text meta description rather than having everything represented in the code itself.
*
*
*
/
public class QuizGUI1 extends javax.swing.JFrame {
	private JButton imageButton1;
	private JButton imageButton3;
	private JPanel jPanel1;
	private JPanel scoreAndStatsTextPanel;
	private JTextArea wordOrSentenceTextArea;
	private JPanel textAndScoreMainPanel;
	private JTextField rightAnswersTextField;
	private JButton mouseRest;
	private JButton exitButton;
	private JButton settingsButton;
	private JButton replayButton;
	private JLabel rightAnswersLabel;
	private JPanel aboutApplicationPanel;
	private JPanel logoPanel2;
	private JPanel logoPanel1;
	private JPanel advertsPanel;
	private JTextField wrongAnswersTextField;
	private JLabel wrongAnswersLabel;
	private JLabel overviewOfNumberOfRightWrongAnswersLabel;
	private JPanel controlButtonPanel;
	private JButton imageButton2;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				QuizGUI1 inst = new QuizGUI1();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public QuizGUI1() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				jPanel1.setBounds(20, 12, 725, 233);
				jPanel1.setLayout(null);
				jPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				{
					imageButton1 = new JButton();
					jPanel1.add(imageButton1);
					imageButton1.setText("jButton1");
					imageButton1.setBounds(12, 5, 225, 221);
				}
				{
					imageButton2 = new JButton();
					jPanel1.add(imageButton2);
					imageButton2.setText("jButton2");
					imageButton2.setBounds(249, 5, 225, 221);
				}
				{
					imageButton3 = new JButton();
					jPanel1.add(imageButton3);
					imageButton3.setText("jButton3");
					imageButton3.setBounds(488, 5, 225, 221);
				}
			}
			{
				textAndScoreMainPanel = new JPanel();
				getContentPane().add(textAndScoreMainPanel);
				textAndScoreMainPanel.setBounds(20, 251, 725, 125);
				textAndScoreMainPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				textAndScoreMainPanel.setLayout(null);
				{
					wordOrSentenceTextArea = new JTextArea();
					textAndScoreMainPanel.add(wordOrSentenceTextArea);
					wordOrSentenceTextArea.setText("wordOrSentenceTextArea");
					wordOrSentenceTextArea.setBounds(10, 7, 706, 40);
				}
				{
					scoreAndStatsTextPanel = new JPanel();
					textAndScoreMainPanel.add(scoreAndStatsTextPanel);
					scoreAndStatsTextPanel.setBounds(380, 54, 333, 59);
					scoreAndStatsTextPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					scoreAndStatsTextPanel.setLayout(null);
					{
						rightAnswersTextField = new JTextField();
						scoreAndStatsTextPanel.add(rightAnswersTextField);
						rightAnswersTextField.setText("0");
						rightAnswersTextField.setBounds(109, 27, 35, 19);
					}
					{
						rightAnswersLabel = new JLabel();
						scoreAndStatsTextPanel.add(rightAnswersLabel);
						rightAnswersLabel.setText("Right answers:");
						rightAnswersLabel.setBounds(13, 29, 84, 15);
					}
					{
						overviewOfNumberOfRightWrongAnswersLabel = new JLabel();
						scoreAndStatsTextPanel.add(overviewOfNumberOfRightWrongAnswersLabel);
						overviewOfNumberOfRightWrongAnswersLabel.setText("Overview of this session.");
						overviewOfNumberOfRightWrongAnswersLabel.setBounds(12, 8, 168, 15);
					}
					{
						wrongAnswersLabel = new JLabel();
						scoreAndStatsTextPanel.add(wrongAnswersLabel);
						wrongAnswersLabel.setText("Wrong answers:");
						wrongAnswersLabel.setBounds(160, 29, 94, 15);
					}
					{
						wrongAnswersTextField = new JTextField();
						scoreAndStatsTextPanel.add(wrongAnswersTextField);
						wrongAnswersTextField.setText("0");
						wrongAnswersTextField.setBounds(260, 27, 35, 19);
					}
				}
				{
					controlButtonPanel = new JPanel();
					textAndScoreMainPanel.add(controlButtonPanel);
					controlButtonPanel.setBounds(6, 53, 362, 60);
					controlButtonPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					controlButtonPanel.setLayout(null);
					{
						replayButton = new JButton();
						controlButtonPanel.add(replayButton);
						replayButton.setText("Replay");
						replayButton.setBounds(6, 7, 79, 25);
					}
					{
						settingsButton = new JButton();
						controlButtonPanel.add(settingsButton);
						settingsButton.setText("Settings");
						settingsButton.setBounds(90, 7, 89, 25);
					}
					{
						exitButton = new JButton();
						controlButtonPanel.add(exitButton);
						exitButton.setText("Exit");
						exitButton.setBounds(182, 7, 61, 25);
						exitButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("exitButton.actionPerformed, event="+evt);
								//TODO add your code for exitButton.actionPerformed
								YesNoToExit.main(new String[]{});
							}
						});
					}
					{
						mouseRest = new JButton();
						controlButtonPanel.add(mouseRest);
						mouseRest.setText("Mouse rest");
						mouseRest.setBounds(248, 7, 105, 25);
					}
				}
			}
			{
				advertsPanel = new JPanel();
				getContentPane().add(advertsPanel);
				advertsPanel.setBounds(20, 382, 725, 190);
				advertsPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				advertsPanel.setLayout(null);
				{
					logoPanel1 = new JPanel();
					//Here we add an image to our interface				
					String path = "//home/ep/data/globability/xtrajava_n_more/little-t/ffcbox.png";
					/*The above path should be changed to be fed by a method accessible by a controller, 
					 * this way the images	can be altered from time to time without changing the 
					 * interface program */
					JLabel label = new JLabel(new ImageIcon(path));
					label.setHorizontalAlignment(JLabel.CENTER);
					logoPanel1.add(label);
					label.setBounds(6, 7, 163, 162);
										
					
					advertsPanel.add(logoPanel1);
					logoPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					logoPanel1.setBounds(7, 7, 175, 175);
					logoPanel1.setLayout(null);
				}
				{
					logoPanel2 = new JPanel();
					//Here we add an image to our interface				
					String path = "//home/ep/data/globability/xtrajava_n_more/little-t/ffcbox.png";
					/*The above path should be changed to be fed by a method accessible by a controller, 
					 * this way the images	can be altered from time to time without changing the 
					 * interface program */
					JLabel label = new JLabel(new ImageIcon(path));
					label.setHorizontalAlignment(JLabel.CENTER);
					logoPanel2.add(label);
					label.setBounds(6, 7, 163, 162);
					advertsPanel.add(logoPanel2);
					// Turning commercials off logoPanel2.setVisible(false);
					logoPanel2.setBounds(540, 7, 175, 175);
					logoPanel2.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					logoPanel2.setLayout(null);
				}
				{
					aboutApplicationPanel = new JPanel();
					//Here we add an image to our interface				
					String path = "//home/ep/data/globability/xtrajava_n_more/little-t/banbox.png";
					/*The above path should be changed to be fed by a method accessible by a controller, 
					 * this way the images	can be altered from time to time without changing the 
					 * interface program */
					JLabel label = new JLabel(new ImageIcon(path));
					label.setHorizontalAlignment(JLabel.CENTER);
					aboutApplicationPanel.add(label);
					label.setBounds(3, 3, 327, 168);
					
					advertsPanel.add(aboutApplicationPanel);
					aboutApplicationPanel.setBounds(194, 7, 334, 175);
					aboutApplicationPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					aboutApplicationPanel.setLayout(null);
				}
			}
			pack();
			this.setSize(767, 618);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

RandomOneOf3Quiz

import java.io.IOException;


/* This class forms the basis for a quiz of the type
 * 
 * "Guess the correct answer between 3 given possibilities".
 * 
 * The RandomOneOf3Quiz will retreive 3 random answers from a datasource, 
 * select which answer will be the correct one and then create an
 * accessible datastructure for any other class that needs to utilize 
 * the answers.
 * 
 * The first version of the Quiz will as the name indicates be of the type
 * one of 3, however later iterations of the Quiz should have added
 * accessor methods that allow for different number of choices and different number 
 * of correct answers or part correct answers as well as adding additional information 
 *to the quizAnswer objects in order to transform the class into a truly multiple choice 
 *type of quiz structure with an extensive numbers of options available
 
 * 
*/
public class RandomOneOf3Quiz {

int passOne;
int passTwo;
int passThree;


public static int lineNumber1;
public static String lineContent1;
public static int isCorrect1;
public static String additionalQuizInformation1;

//TODO

//create vector instead!!!!!!
public static String[] quizAnswer1 = {""+ lineNumber1, "" +lineContent1, ""+ isCorrect1, ""+ additionalQuizInformation1}; 

//                  array quizAnswer2 [int lineNumber2, String lineContent2, int isCorrect2, String additionalQuizInformation2]
   //                array quizAnswer3 [int lineNumber3, String lineContent2, int isCorrect3, String additionalQuizInformation3]


	public static void main(String[] args) {
		
		/* Meta runthrough of class action

		A number of possible answers is determined (number = 3)

		In order to make the quiz unpredictable randoms are requested from
		the class RealSimpleRandomGenerator


		TODO 1) ask realSimpleRandomGenerator for 3 randoms
		*/
		
		
		RealSimpleRandomGenerator.main(new String[]{}); 		

System.out.println("This is the first random variable "+ RealSimpleRandomGenerator.passOne);

System.out.println("This is the second random variable "+ RealSimpleRandomGenerator.passTwo);

System.out.println("This is the third random variable "+ RealSimpleRandomGenerator.passThree);

/*
TODO 2) place said numbers in quiz dataobject/s.

The numbers are placed within a datastructure like below

array quizAnswer1 [int lineNumber1, String lineContent1, int isCorrect1]
array quizAnswer2 [int lineNumber2, String lineContent2, int isCorrect2]
array quizAnswer3 [int lineNumber3, String lineContent3, int isCorrect3]

Later iterations of the above needs a hashmap or similar structure
containing the information as to make it possible to grow the quiz
to an "infinite number of possibilities" (limited by datastructure capability)

Efficient structure minimizing memory used for the data structure needs
to be deviced, like possibly dividing the memory structure into 2 parts 
one for answers and one for specifying the correct answers. One could be 100'eds
of lines and the other just 3 and parsing through hundreds to find
3 is inefficient so multiple structures could be a good idea. But enough about that for now. 
*/

// inserting the first value into quizAnswer1 array

System.out.println("Put this value in the vector"+ RealSimpleRandomGenerator.passOne);

lineNumber1 = RealSimpleRandomGenerator.passOne;



//quizAnswer1[0] = lineNumber1;

//System.out.println("Print value of array "+ linenumber1);
System.out.println("content of array :pos 0:" + quizAnswer1[0].toString());

//System.out.println(Arrays.toString(arry));



/*

Now we know what to look for and we proceed to read from our datasource in order to
build the next part of our quiz dataobject/s

In order to do this we need to read the specific line numbers given by our
quiz dataobject/s.

The datasource from which to read from is specified, the first iteration gets 
answers from a <CR/EOL> separated textfile in which the structure is 
as follows:

... Sample piece from file ...
0/ingenting P377.SPR
1/en P368.SPR
2/to P369.SPR
3/tre P370.SPR
4/fire P371.SPR
5/fem P372.SPR
6/seks P373.SPR
.....

Later iterations should be able to point to dirrerent data sources,
such as files to read from, databases etc. 

But for now our datasource is:

Chp01.txt

Taking into consideration that each line in our first iteration data source
contains more than just an answer, we actually get the image we are 
going to use we might as well expand our quiz dataobject/s to hold 
additional information for now, coming iterations should move
towards using an independant data structure in order to make the 
quiz class completely independant from the datasources and merely 
-an abstractation over the theme multiple choice quiz.


array quizAnswer1 [int lineNumber1, String lineContent1, int isCorrect1, String additionalQuizInformation1]
array quizAnswer2 [int lineNumber2, String lineContent2, int isCorrect2, String additionalQuizInformation2]
array quizAnswer3 [int lineNumber3, String lineContent2, int isCorrect3, String additionalQuizInformation3]

TODO 3) Reading answers into the quizAnswer objects.

Let us look at the first line and separate it into quizAnswer1

We'll be operating under the premise that the random generator has done its work and
the random given for quizAnswer1 actually was one

 Line one in our datafile looks like this
 
0/ingenting P377.SPR

When we are parsing the line if we're smart we do it in reverse,
thus we are saving ourselves parsing time.

So we read from the last character of the line which is always R followed 
by PS. then a numerical and finally a capital P followed by a blankspace
(this can come in useful if we start writing tests and the like)

So we have P377.SPR

This information falls into the category

Additional quiz information, and it should thus be placed in the 

String additionalQuizInformation

Our quizAnswer1 object will thus look like this now.

quizAnswer1 = [1, String lineContent1, int isCorrect1, P377.SPR]

We then take the remainder of the string we haven't parsed and place it in the
corect place in our array. We leave out the blankspace as we have no use for it.
Inserting blankspace on screen for sentences etc. is left to the
classes operating in that part of a potential system using this class.

But now our data object looks like this

quizAnswer1 = [1, 0/ingenting, int isCorrect1, P377.SPR]

It might look as if there is a problem with comma as a separator in 
case we are operating with whole sentences, but the comma separation
in the quizAnswer object is merely a human readable representation of 
the datastructure and the sentence if more than one word, will be contained
within the Structures of the array.

We need to repeat the steps above for the second and third data object.

TODO 4) Decide which answer should be the correct one 

As this is a random multiple choice quiz we simply let the the random generator decide
Thus the correct name of this quiz should probably have been 
RandomOneof3Quiz, once the quiz is up and running this should be changed before
the class is implemented in a system where other classes call it.

However knowing we need one of 3 we ask the RealSimpleRandomGenerator
to throw us a number between 1 and 3.

insert code here

As we now know which answer will be correct we insert the correct answer
into the quizAnswer objects.

Being smart we have already decided that the value 0 of our isCorrect1/2/3 
objects means the answer is incorrect, we only need to change the value
of one object in one of our quizAnswer objects.

For the sake of argument and recycling say our random generator
gave us the number one then our task is to select the correct quizAnswer
object and set the isCorrect value to 1

That means our object looks like this

quizAnswer1 = [1, 0/ingenting, 1, P377.SPR]

TODO insert code here to select correct quiZanswer object and insert
isCorrect value into slot 3 of the array.
 

*/

System.out.println("Now we have 3 quizAnswer objects, each holding a number of values, we have read \ninto them. And all we have to do is for someone to interact with our class");

	}
}

/*
Now we have 3 quizAnswer objects, each holding a number of values
we have read into them

And all we have to do is for someone to interact with our class.

For this to happen we need a number of accessor methods


One would be to start the quiz

startRandomOneOf3Quiz() - This method should invoke the quiz program

TODO create accessor method startRandomOneOf3Quiz()

isThisTheCorrectAnswer(int isNumberCorrect) - This method calls a check of the 
quizAnswer object given by the isNumberCorrect, the check looks at
slot 3 of the array, if the answer is 0 then it returns yourAnswerIsIncorrect
and if answer is 1 then it returns yourAnswerIsCorrect.

TODO create accessor method isThisTheCorrectAnswer(int isNumberCorrect)

It is probable one in later iterations of the quiz class structure 
should implement a "truth checker" class with different abstractions 
on truthchecks on different parameters so that one could implement the
truthchecker in various ways in various settings. 
 
The accessor method

giveMeFurtherInformationFrom(int quizAnswerNumber, int slotNumber) 

Provides information on what is in a particular quizAnswer array's slotnumber
here the accessor needs to be able to return data in a various of ways depending
upon the information that is requested.

This method can be used to extract string values for both picture to display as well
as string values for what text is in question etc. 

TODO create accessor method giveMeFurtherInformationFrom(int quizAnswerNumber, int slotNumber)


*/


RealSimpleRandomGenerator

/* RealSimpleRandomGenerator
 * 
 * This class produces 3 random numbers upon request.
 * 
 *  This class needs to be expanded so that you can call the 
 *  random generator class requesting a specific number of random 
 *  numbers using accessor method, it also needs to be expanded from
 *  encompassing random integers only to having the possibility
 *  for expanding the range to negative numbers as well
 *  
 *  Also it will need the possibility to be influenced by
 *  exclusion criteria such as a function zeroNotWanted that sets
 *  a value excludeZeroIs to 1 or other if you do not want the 
 *  random generator to give you a zero when you ask it for a number */

import java.util.Random;

public class RealSimpleRandomGenerator {

	protected static int nMax;
	public static int numberOne = 1;
	public static int numberTwo = 1;
	public static int numberThree = 1;
	public static int passOne;
	public static int passTwo;
	public static int passThree;
	
	public static void main(String[] args) {
		
		//Creating a random object
		Random rand = new Random();
		
		/* Getting the top of the range from which we want randoms 
		0 to nMax */ 
		getNMax();

		//Creating the 3 random numbers
		int randomNum1=rand.nextInt(nMax);
		
		
		int randomNum2=rand.nextInt(nMax);
		int randomNum3=rand.nextInt(nMax);
		
		//Verification visually, that the numbers are being created
		System.out.println("Hello World: "+ randomNum1);
		
		System.out.println("Hello World: "+ randomNum2); 
	
		System.out.println("Hello World: "+ randomNum3); 
		
		
	   //Something wrong in this else if all are changed to 1, create case instead 
	  if (randomNum1 <= 0){  
	              randomNum1=1;
	              System.out.println("The random number for random 1 was changed to 1!");
	  } else 
	  {
		  if (randomNum2 <= 0){  
              randomNum2=1;
              System.out.println("The random number for random 2 was changed to 1!");
     } 
	   else 
	  {
		  if (randomNum3 <= 0){  
              randomNum3=1;
     System.out.println("The random number for random 3 was changed to 1!");
     } 
		numberOne = randomNum1;
		numberTwo = randomNum2;
		numberThree = randomNum3; }}
		
		System.out.println("Hello World: "+ numberOne);
		System.out.println("Hello World: "+ numberTwo);
		System.out.println("Hello World: "+ numberThree);
    
	    //Creating variables to pass;
		
	    passOne = numberOne;
	    passTwo = numberTwo;
	    passThree = numberThree;
	    
		numberOne = 0;
		numberTwo = 0;
		numberThree = 0;
		}

	public static int getNMax() {
		setNMax(nMax);
		return nMax;
	}

	public static void setNMax(int max) {
		max = 90; 
		/* once called from outside this class should called with
       something like RealSimpleRandomGenerator.setNMax(90); 
       We have to remove the fixed number for max here */
		nMax = max;
		
	} 
	
}
	


Start

import java.io.IOException;


public class Start {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws IOException, InterruptedException {
	
		//TODO show splashscreen
		
		
		//Initialize soundexchange (SOX) so it can be used by the program  
		try {
	        String line;
	        Process p = Runtime.getRuntime().exec("sox");
	     p.waitFor();
	       // System.out.println( p.exitValue() );
	        } finally {} 
  		      
		
	//TODO initialize interface according to previously selected settings
	//TODO launch the set up of a datacollection of images/sounds/video pointers

	        //TODO Launch whatever interface the initialization comes up with for now hardcoded

	        StartChangeSwitchGUI.main(new String[]{}); 
	        
	/*TODO - Forcibly remove this class from memory - Or should
	  we create a thread so that we have a permanent reference to 
	  other objects we need during the running process */      
} 
}
	

StartChangeSwitchGUI

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;

import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/

//TODO create a singleton structure for the entire GUI so it is only created once.

public class StartChangeSwitchGUI extends javax.swing.JFrame {
	private JPanel mainPanel;
	private JButton startLearningModeButton;
	private JCheckBox startLearningModeAutomatically;
	private JButton exitButton;
	private JPanel exitButtonPanel;
	private JButton startReportViewButton;
	private JCheckBox startReportViewAutomatically;
	private JEditorPane explanationPanel;
	private JPanel jPanel1;
	private JButton startQuizButton;
	private JCheckBox startQuizAutomatically;
	private JCheckBox startEditSettingsAutomatically;
	private JButton EditProgramDatabaseAndQuizSettingsButton;
	private JPanel buttonPanel;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				StartChangeSwitchGUI inst = new StartChangeSwitchGUI();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public StartChangeSwitchGUI() {
		super("Switch Gui");
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				mainPanel = new JPanel();
				getContentPane().add(mainPanel, BorderLayout.CENTER);
				mainPanel.setLayout(null);
				mainPanel.setPreferredSize(new java.awt.Dimension(409, 358));
				{
					buttonPanel = new JPanel();
					mainPanel.add(buttonPanel);
					buttonPanel.setBounds(12, 14, 385, 262);
					buttonPanel.setLayout(null);
					buttonPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					{
						EditProgramDatabaseAndQuizSettingsButton = new JButton();
						buttonPanel.add(EditProgramDatabaseAndQuizSettingsButton);
						EditProgramDatabaseAndQuizSettingsButton.setText("Edit Program, Database and Quiz settings");
						EditProgramDatabaseAndQuizSettingsButton.setBounds(60, 95, 299, 22);
						EditProgramDatabaseAndQuizSettingsButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("EditProgramDatabaseAndQuizSettingsButton.actionPerformed, event="+evt);
								//TODO add your code for EditProgramDatabaseAndQuizSettingsButton.actionPerformed
							}
						});
					}
					{
						startLearningModeButton = new JButton();
						buttonPanel.add(startLearningModeButton);
						startLearningModeButton.setText("Start Learning Mode");
						startLearningModeButton.setBounds(60, 133, 298, 22);
						startLearningModeButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startLearningModeButton.actionPerformed, event="+evt);
								//TODO add your code for startLearningModeButton.actionPerformed
								LearningModeGUI.main(new String[]{}); 
								//TODO move the launch into into StartChangeSwitchGUIController and instead call the relevant accessor in the controller.
								//this way we can implement the MVC pattern (Model-View-Controller)
							}
						});
					}
					{
						startLearningModeAutomatically = new JCheckBox();
						buttonPanel.add(startLearningModeAutomatically);
						startLearningModeAutomatically.setBounds(12, 133, 31, 17);
						startLearningModeAutomatically.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startLearningModeAutomatically.actionPerformed, event="+evt);
								//TODO add your code for startLearningModeAutomatically.actionPerformed
							}
						});
					}
					{
						startEditSettingsAutomatically = new JCheckBox();
						buttonPanel.add(startEditSettingsAutomatically);
						startEditSettingsAutomatically.setBounds(11, 96, 32, 17);
						startEditSettingsAutomatically.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startEditSettingsAutomatically.actionPerformed, event="+evt);
								//TODO add your code for startEditSettingsAutomatically.actionPerformed
							}
						});
					}
					{
						startQuizAutomatically = new JCheckBox();
						buttonPanel.add(startQuizAutomatically);
						startQuizAutomatically.setBounds(12, 172, 31, 17);
						startQuizAutomatically.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startQuizAutomatically.actionPerformed, event="+evt);
								//TODO add your code for startQuizAutomatically.actionPerformed
							}
						});
					}
					{
						startQuizButton = new JButton();
						buttonPanel.add(startQuizButton);
						startQuizButton.setText("Start Quiz");
						startQuizButton.setBounds(60, 170, 298, 22);
						startQuizButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startQuizButton.actionPerformed, event="+evt);
								/*TODO move code for startQuizButton.actionPerformed to controller 
								 * (thus a multiple number of quizzes can be launched independently 
								 * based on selections made elsewhere and stored in the program
								 * settings. Or This button could launch a quiz selection interface 
								 * (that could be automated like this one). 
								 */ 
								QuizGUI1.main(new String[]{});
							}
						});
					}
					{
						jPanel1 = new JPanel();
						buttonPanel.add(jPanel1);
						jPanel1.setBounds(13, 14, 359, 69);
						jPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
						jPanel1.setLayout(null);
						{
							explanationPanel = new JEditorPane();
							jPanel1.add(explanationPanel);
							explanationPanel.setText("Make a selection if you wish the program to automatically start with a particular option every time you launch the     application.");
							explanationPanel.setBounds(9, 10, 341, 49);
							explanationPanel.setEditable(false);
							explanationPanel.setOpaque(false);
						}
					}
					{
						startReportViewAutomatically = new JCheckBox();
						buttonPanel.add(startReportViewAutomatically);
						startReportViewAutomatically.setBounds(13, 216, 30, 19);
						startReportViewAutomatically.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startReportViewAutomatically.actionPerformed, event="+evt);
								//TODO add your code for startReportViewAutomatically.actionPerformed
							}
						});
					}
					{
						startReportViewButton = new JButton();
						buttonPanel.add(startReportViewButton);
						startReportViewButton.setText("Start Report View");
						startReportViewButton.setBounds(60, 215, 298, 22);
						startReportViewButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("startReportViewButton.actionPerformed, event="+evt);
								//TODO add your code for startReportViewButton.actionPerformed
							}
						});
					}
				}
				{
					exitButtonPanel = new JPanel();
					mainPanel.add(exitButtonPanel);
					exitButtonPanel.setBounds(12, 288, 385, 65);
					exitButtonPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					exitButtonPanel.setLayout(null);
					{
						exitButton = new JButton();
						exitButtonPanel.add(exitButton);
						exitButton.setText("Exit");
						exitButton.setBounds(298, 19, 75, 22);
						exitButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out.println("exitButton.actionPerformed, event="+evt);
								//TODO add your code for exitButton.actionPerformed
								YesNoToExit.main(new String[]{});
							}
						});
					}
				}
			}
			pack();
			this.setSize(419, 395);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		//TODO Edit Program, Database and Quiz settings button
		//TODO Start Learning Mode button
		//TODO Start Quiz button
		/*TODO Selection boxes for each that if selected go directly to
		to the selected mode after a timeout period */
	}

}

YesNoToExit

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/

public class YesNoToExit extends javax.swing.JFrame {
	private JPanel messagePanel;
	private JButton yesButton;
	private JButton cancelButton;
	private JLabel areYouSureYouWantToExitLabel;
	private JPanel buttonPanel;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				YesNoToExit inst = new YesNoToExit();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public YesNoToExit() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			setSize(400, 180);
			{
				messagePanel = new JPanel();
				getContentPane().add(messagePanel);
				messagePanel.setBounds(12, 12, 362, 46);
				messagePanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				messagePanel.setLayout(null);
				{
					areYouSureYouWantToExitLabel = new JLabel();
					messagePanel.add(areYouSureYouWantToExitLabel);
					areYouSureYouWantToExitLabel.setText("Are you sure you want to exit ?");
					areYouSureYouWantToExitLabel.setBounds(77, 16, 206, 15);
				}
			}
			{
				buttonPanel = new JPanel();
				getContentPane().add(buttonPanel);
				buttonPanel.setBounds(12, 70, 362, 56);
				buttonPanel.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				buttonPanel.setLayout(null);
				{
					yesButton = new JButton();
					buttonPanel.add(yesButton);
					yesButton.setText("Yes");
					yesButton.setBounds(33, 13, 70, 25);
					yesButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("yesButton.actionPerformed, event="+evt);
							//TODO add your code for yesButton.actionPerformed
							System.exit(0);
						}
					});
				}
				{
					cancelButton = new JButton();
					buttonPanel.add(cancelButton);
					cancelButton.setText("Cancel");
					cancelButton.setBounds(245, 13, 76, 25);
					cancelButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("cancelButton.actionPerformed, event="+evt);
							//TODO add your code for cancelButton.actionPerformed
							dispose();
						}
					});
				}
			}
			//pack();
			//this.setSize(401, 175);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

FlashCardQuizController

/* This class is the controller logic for the flashcard type quiz
 * used by Little-T in which the user has to select one image 
 * from 3 presented different ones on a screen in a GUI.
 * 
 * You will find a meta explanation of the functionality in a number
 * of todo's below
 * 
 * Eventually this class needs to be abstracted so that users can 
 * choose from a range of options as to which type of quiz to run etc.
 * 
 * 
 */

public class FlashCardQuizController {


/* TODO: Figure out which type of quiz

For the first quiz we have decided to go with the RandomOneOf3Quiz,
a simple selection of 3 questions and the corresponding answers, 
these can in turn be used to build our GUI with corresponding 
sounds and images
 

We know the pictures are numbered from say 1 to 99

We also know we need to select 3 pictures

So we need to call the quiz called RandomOneOf3Quiz

Now we need to select which answer is going to be the correct one
we do that by sending a query to our random generator asking it for 1 number
ranging from 1 to 3, this number we place in a variable called
correctAnswer */

}
java_effort_littlet.txt · Last modified: 2012/03/30 01:32 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki



The contents of this site, i.e. texts, programs and images, but not limited to these, belongs to their respective owners and are protected under international copyright treaties according to individual licensing.

Please make sure you familiarize yourself with the appropriate permissions / licenses and follow these individually before using anything you find on this site.

The Global Ability Initiative is a Non Profit venture dedicated to the development of gratis, open source software for the disabled, the sick and the needy - We aim to provide assistive software to a wide variety of people, suffering for example from Aphasia, MS, ALS, Cerebral Palsy and other disabilities as well as pushing initiatives in the field of ECG monitoring.

With reservation for changes and errors.