<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JosteinB &#187; Programming</title>
	<atom:link href="http://josteinb.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://josteinb.com</link>
	<description>The blog with the awesome slogan</description>
	<lastBuildDate>Fri, 26 Mar 2010 17:31:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Neptune&#8217;s Pride Battle Calculator v0.3</title>
		<link>http://josteinb.com/2010/03/neptunes-pride-battle-calculator-v0-3/</link>
		<comments>http://josteinb.com/2010/03/neptunes-pride-battle-calculator-v0-3/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 17:09:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[battle calculator]]></category>
		<category><![CDATA[Neptunes pride]]></category>
		<category><![CDATA[npCalc]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=137</guid>
		<description><![CDATA[I&#8217;ve upgraded the calculator a little, tinkered a bit with the design with a new header and some minor tweaks for better appearance, and managed to get the javascript to run in IE as well, thanks to a little help from saiboten. What went wrong was as simple as using type=&#8221;text/javascript&#8221; for javascripts in stead [...]


Related posts:<ol><li><a href='http://josteinb.com/2010/03/neptunes-pride-battle-calculator/' rel='bookmark' title='Permanent Link: Neptune&#8217;s Pride Battle Calculator'>Neptune&#8217;s Pride Battle Calculator</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve upgraded the calculator a little, tinkered a bit with the design with a new header and some minor tweaks for better appearance, and managed to get the javascript to run in IE as well, thanks to a little help from <a title="saiboten" href="http://saiboten.com/blog" target="_self">saiboten</a>.</p>
<p>What went wrong was as simple as using type=&#8221;text/javascript&#8221; for javascripts in stead of type=&#8221;application/javascript&#8221;. gah.</p>
<p>As allways, feedback is appreciated!</p>
<p>the new version is located <a title="npCalc v0.3" href="http://josteinb.com/npCalc" target="_self">here</a>.</p>
<p>The old versions can still be found here if anything stops working for you:</p>
<p><a title="npCalc v0.1" href="http://josteinb.com/npCalc/v01" target="_self">version 0.1</a></p>
<p><a title="npCalc v0.2" href="http://josteinb.com/npCalc/v02" target="_self">version 0.2</a></p>


<p>Related posts:<ol><li><a href='http://josteinb.com/2010/03/neptunes-pride-battle-calculator/' rel='bookmark' title='Permanent Link: Neptune&#8217;s Pride Battle Calculator'>Neptune&#8217;s Pride Battle Calculator</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2010/03/neptunes-pride-battle-calculator-v0-3/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Neptune&#8217;s Pride Battle Calculator</title>
		<link>http://josteinb.com/2010/03/neptunes-pride-battle-calculator/</link>
		<comments>http://josteinb.com/2010/03/neptunes-pride-battle-calculator/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 14:18:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[battle calculator]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Neptunes pride]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=129</guid>
		<description><![CDATA[I got introduced to Neptune&#8217;s Pride a little while ago by a friend&#8230; It is a simple 4X game, with small games for 8 players in each in the free ones. The game uses some simple math to calculate the outcome of battles, and since I am lazy I got tired of doing that math [...]


Related posts:<ol><li><a href='http://josteinb.com/2010/03/neptunes-pride-battle-calculator-v0-3/' rel='bookmark' title='Permanent Link: Neptune&#8217;s Pride Battle Calculator v0.3'>Neptune&#8217;s Pride Battle Calculator v0.3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I got introduced to <a href="http://np.ironhelmet.com" target="_blank">Neptune&#8217;s Pride</a> a little while ago by a friend&#8230; It is a simple 4X game, with small games for 8 players in each in the free ones.</p>
<p>The game uses some simple math to calculate the outcome of battles, and since I am lazy I got tired of doing that math and started working on a battle calculator.</p>
<p>This is my first attempt on php, and it is a work in progress&#8230; so feedback is appreciated.</p>
<p>Try it out here: <a title="Neptunes Pride Battle Calculator" href="http://josteinb.com/npCalc" target="_self">Neptune&#8217;s Pride Battle Calculator</a></p>
<p>UPDATE:</p>
<p>I have ditched php, and gone for javascript in v0.2 of the calculator&#8230; Now the workflow is more streamlined since you don&#8217;t have to go between different pages to get to results.  Seems to be some css-problems though. And javascript issues with IE. Working on it.</p>
<p>&#8230;And apparently IE doesn&#8217;t care about height / min-height unless you add an !important to it.</p>
<p>the old version can still be found <a title="np battle calculator v0.1" href="http://josteinb.com/npCalc/v01" target="_blank">here</a></p>


<p>Related posts:<ol><li><a href='http://josteinb.com/2010/03/neptunes-pride-battle-calculator-v0-3/' rel='bookmark' title='Permanent Link: Neptune&#8217;s Pride Battle Calculator v0.3'>Neptune&#8217;s Pride Battle Calculator v0.3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2010/03/neptunes-pride-battle-calculator/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Making international characters searchable in LaTeX documents</title>
		<link>http://josteinb.com/2010/01/making-international-characters-searchable-in-latex-documents/</link>
		<comments>http://josteinb.com/2010/01/making-international-characters-searchable-in-latex-documents/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 12:01:58 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[font encoding]]></category>
		<category><![CDATA[international characters]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=119</guid>
		<description><![CDATA[By default LaTeX generates some international characters in a weird way when building a PDF and so on. For example, the norwegian Å will be represented as ˚A, and thus making any word containing the letter impossible to find when searching for it. This can be solved by using the package fontenc, with the parameter T1 [...]


Related posts:<ol><li><a href='http://josteinb.com/2009/12/citing-displaying-source-code-in-latex/' rel='bookmark' title='Permanent Link: Citing / displaying source code in LaTeX'>Citing / displaying source code in LaTeX</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>By default LaTeX generates some international characters in a weird way when building a PDF and so on. For example, the norwegian Å will be represented as ˚A, and thus making any word containing the letter impossible to find when searching for it. This can be solved by using the package fontenc, with the parameter T1 like this:</p>
<p>\usepackage[T1]{fontenc}</p>
<p>Now everything (at least for norwegian documents) should be working as expected.</p>


<p>Related posts:<ol><li><a href='http://josteinb.com/2009/12/citing-displaying-source-code-in-latex/' rel='bookmark' title='Permanent Link: Citing / displaying source code in LaTeX'>Citing / displaying source code in LaTeX</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2010/01/making-international-characters-searchable-in-latex-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful BASH-command: !!</title>
		<link>http://josteinb.com/2009/12/useful-bash-command/</link>
		<comments>http://josteinb.com/2009/12/useful-bash-command/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 14:26:28 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=112</guid>
		<description><![CDATA[When ever you use the terminal in Linux or OS X, and forget to add sudo in front of a command that needs the privileges, you can simply type sudo !! to run the same command with sudo. awesome. &#8220;!!&#8221; Will repeat the last issued command, and can probably be used for other useful things, [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>When ever you use the terminal in Linux or OS X, and forget to add sudo in front of a command that needs the privileges, you can simply type sudo !! to run the same command with sudo. awesome. &#8220;!!&#8221; Will repeat the last issued command, and can probably be used for other useful things, too.</p>
<p>Thanks, Peder 2.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2009/12/useful-bash-command/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Citing / displaying source code in LaTeX</title>
		<link>http://josteinb.com/2009/12/citing-displaying-source-code-in-latex/</link>
		<comments>http://josteinb.com/2009/12/citing-displaying-source-code-in-latex/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 12:24:58 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[listing]]></category>
		<category><![CDATA[lstlisting]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=96</guid>
		<description><![CDATA[I am writing my master thesis using LaTeX, a typesetting system most commonly used for scientific documents.  Since my thesis is in computer science, I have the need to display a fair amount of code.  After searching around the net and with some trial and error, I have come up with some settings that does [...]


Related posts:<ol><li><a href='http://josteinb.com/2010/01/making-international-characters-searchable-in-latex-documents/' rel='bookmark' title='Permanent Link: Making international characters searchable in LaTeX documents'>Making international characters searchable in LaTeX documents</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am writing my master thesis using <a title="latex project" href="http://www.latex-project.org/" target="_self">LaTeX</a>, a typesetting system most commonly used for scientific documents.  Since my thesis is in computer science, I have the need to display a fair amount of code.  After searching around the net and with some trial and error, I have come up with some settings that does this in a nice way.</p>
<p>It is based on the listings package, we define a lstset that handles the code.  This in combination with a nice caption makes for a nice presentation of source code.</p>
<p>Here is the final result:</p>
<div id="attachment_97" class="wp-caption alignnone" style="width: 460px"><img class="size-full wp-image-97 " title="latex_screenshot" src="http://josteinb.com/wp-content/uploads/2009/12/latex_screenshot1.png" alt="LaTeX Source Code Screenshot" width="450" height="169" /><p class="wp-caption-text">LaTeX Source Code Screenshot</p></div>
<p>&#8220;Read more&#8221; for the rest of the article</p>
<p><span id="more-96"></span></p>
<p>The packages needed are:</p>
<ul>
<li>\usepackage{listings}</li>
<li>\usepackage{cite}</li>
<li>\usepackage{caption}</li>
<li>\usepackage{upquote}</li>
<li>\usepackage{xcolor}</li>
<li>\usepackage{xcolor}</li>
</ul>
<p>We now define the caption as:</p>
<p>\DeclareCaptionFont{white}{\color{white}}<br />
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}<br />
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}</p>
<p>This makes a gray box for the caption, with white text.</p>
<p>Now define the lstset with the following:</p>
<p>\lstset{<br />
language=Java,<br />
keywordstyle=\bfseries\ttfamily\color[rgb]{0,0,1},<br />
identifierstyle=\ttfamily,<br />
commentstyle=\color[rgb]{0.133,0.545,0.133},<br />
stringstyle=\ttfamily\color[rgb]{0.627,0.126,0.941},<br />
showstringspaces=false,<br />
basicstyle=\small,<br />
numberstyle=\footnotesize,<br />
numbers=left,<br />
stepnumber=1,<br />
numbersep=10pt,<br />
tabsize=2,<br />
breaklines=true,<br />
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},<br />
breakatwhitespace=false,<br />
aboveskip={1.5\baselineskip},<br />
columns=fixed,<br />
upquote=true,<br />
extendedchars=true,<br />
frame=bottomline,<br />
inputencoding=utf8<br />
}</p>
<p>The language must obviously be changed to the language  you are using, to provide the correct syntax coloring.</p>
<p>the numbers parameter chooses whether to show line numbers or not, the prebreak parameter adds an arrow to indicate that the line is broken.  The upquote parameter ensures that no fancu &#8220;&#8216;s are used, so that you can copy the code and still be able to run it.  The other parameters should be self-explanatory, and can be modified as you see fit.</p>
<p>To use this in your document, you can insert code directly with:</p>
<p>\begin{lstlisting}[label=some-samplecode, caption=Example for code straight from the .tex file]</p>
<p>&lt;insert code here&gt;</p>
<p>\end{lstlisting}</p>
<p>or you can insert code from an external file using:</p>
<p>\lstinputlisting[label=samplecode,caption=Example for code from a file]{sourceCode/K53.java}</p>
<p>all of these can now be referenced from other places in the document with the \ref{labelname} command, and will show up in your overview of listings.</p>


<p>Related posts:<ol><li><a href='http://josteinb.com/2010/01/making-international-characters-searchable-in-latex-documents/' rel='bookmark' title='Permanent Link: Making international characters searchable in LaTeX documents'>Making international characters searchable in LaTeX documents</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2009/12/citing-displaying-source-code-in-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple quiz-program in Python</title>
		<link>http://josteinb.com/2009/05/simple-quiz-program-in-python/</link>
		<comments>http://josteinb.com/2009/05/simple-quiz-program-in-python/#comments</comments>
		<pubDate>Fri, 01 May 2009 11:42:33 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[quiz]]></category>
		<category><![CDATA[studying]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=56</guid>
		<description><![CDATA[When we were studying for exams, Tobias and Peder1 decided to make some tools to help us study.  This is Tobias&#8217; version, written in Python. &#8220;The program is fairly simple. You select a text file containing lines with topics you want to learn, and then you have to type inn all of them. The program [...]


Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-written-in-java/' rel='bookmark' title='Permanent Link: Simple quiz-program written in Java'>Simple quiz-program written in Java</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When we were studying for exams, <a title="saiboten" href="http://saiboten.com" target="_self">Tobias</a> and <a title="truben" href="http://truben.no/journal" target="_self">Peder1</a> decided to make some tools to help us study.  This is Tobias&#8217; version, written in Python.</p>
<p>&#8220;The program is fairly simple. You select a text file containing lines with topics you want to learn, and then you have to type inn all of them. The program writes how many topics are left, and can also give you hints if you need it. You are finished when you have written all topics, or have given up by typing “stop”. Then it writes out how long time you used.&#8221;</p>
<p>Read more for the code</p>
<p><span id="more-56"></span></p>
<pre lang="Python">import time
import os

avail_topics_in_file = []
topics = []

#Traverse folder
for root, dirs, files in os.walk("."):
    for file in files:
        #Check if file ends with .txt
        if file.endswith(".txt"):
            avail_topics_in_file.append(file)

#print topics
print "Select topic:"
for i in range(0,len(avail_topics_in_file)):
    print i+1,avail_topics_in_file[i]

#find topic
selected_topic = int(raw_input())-1
chosen_file = avail_topics_in_file[selected_topic]

print "You have selected",chosen_file.split(".")[0] + "."

#Run through file and add each line to topics
f = open(chosen_file)
for line in f:
    topics.append(line.strip())

#Save answer to answer-variable
answer = topics
topics_len = len(topics)

#Initialize array and number of found topics.
found_topics = []
found_topics_len = 0

#Save number of hints used, and how many character we show for each hint
used_hints = 0
helpchars = 2

start = time.time()

#Function which print strint with the title function
def print_title(x):
    print x.title()

#Function which prints all entries in the list.
def print_all_from_list(list):
    map(lambda x: print_title(x),list)

print "To recieve a hint, please type \"hint\"."

#Loop which runs until all topics are found or user breaks it by typing "stop"
while True:
    print "Here are your currently solved words:"

    #Check how many hints are left
    if 5-used_hints &lt; 0:
        hint_text = 0
    else:
        hint_text = 5 - used_hints
    print "You have " + str(hint_text) + " hint igjen."

    #Print all found topics
    for i in found_topics:
        print "-" ,i

    #print number of found topics / all topics.
    print found_topics_len , "of" , topics_len

    #Get new input
    input = raw_input().lower()

    #check if input is one of the answers, and remove it if it is.
    if input in topics:
        for i in range(0, topics_len):
            if input == topics[i-1]:
                topics.pop(i-1)
                break

        #Increase number of found topics, and add it to the found_topics-list.
        found_topics_len += 1
        found_topics.append(input)

        #Reset the helpindex
        helpchars = 2

        #Check if all topics are found and print some information
        if found_topics_len == topics_len:
            print "\nHurray! You won the game!"
            time_used = time.time() - start
            print "You needed " + str(used_hints) + " hints and used" ,
            str('%.2f'%(time_used))  + " seconds in total.\n"
            print "Here are the answers:"
            print_all_from_list(found_topics)
            break
    #user wants a hint.
    elif input == "hint":
        if(used_hints &lt; 5):
            print "\nHint:" , topics[0][0:helpchars]
        else:
            print "Du er tom for hint!"
        helpchars += +2
        used_hints += 1

    #user wants to stop.
    elif input == "stop":
        print "You gave up. Poor you. Here's the answers:"
        print_all_from_list(answer)
        break
    else:
        #Word is not found.
        print "Word not found. Sorry"
    print "\n"</pre>


<p>Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-written-in-java/' rel='bookmark' title='Permanent Link: Simple quiz-program written in Java'>Simple quiz-program written in Java</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2009/05/simple-quiz-program-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple quiz-program written in Java</title>
		<link>http://josteinb.com/2009/05/simple-quiz-program-written-in-java/</link>
		<comments>http://josteinb.com/2009/05/simple-quiz-program-written-in-java/#comments</comments>
		<pubDate>Fri, 01 May 2009 11:30:07 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[quiz]]></category>
		<category><![CDATA[studying]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=64</guid>
		<description><![CDATA[This is Peders version of the quiz program for studying.  it takes textfiles with the extention .pugg as input import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Pugge { public static void main(String[] args) throws IOException { Map wordLists = new HashMap(); File f = new File("."); for(String filen [...]


Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-in-python/' rel='bookmark' title='Permanent Link: Simple quiz-program in Python'>Simple quiz-program in Python</a></li>
<li><a href='http://josteinb.com/2009/03/prepared-statements-in-java/' rel='bookmark' title='Permanent Link: Prepared Statements in Java'>Prepared Statements in Java</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is <a title="truben" href="http://truben.no/journal" target="_self">Peders</a> version of the quiz program for studying.  it takes textfiles with the extention .pugg as input<br />
<span id="more-64"></span></p>
<pre lang="java">
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Pugge {

	public static void main(String[] args) throws IOException {

		Map<string, Map<string,Boolean>> wordLists = new HashMap<string, Map<string,Boolean>>();

		File f = new File(".");
		for(String filen : f.getCanonicalFile().list()) {
			if(filen.endsWith(".pugg"))
				wordLists.put(filen, getWords(filen));
		}

		System.out.println("Velkommen! Hva vil du pugge?\n");
		int tell = 1;
		for(String s : wordLists.keySet()) {
			System.out.println(tell++ + ". " + s.substring(0, s.length()-5));
		}
		Scanner inn = new Scanner(System.in);

		System.out.print("\nSkriv inn valg: ");
		String tema =  (String) wordLists.keySet().toArray()[Integer.parseInt(inn.nextLine())-1];
		String temaEase =  toProperCase(tema.substring(0, tema.length()-5));

		Map<string,Boolean> ord = wordLists.get(tema);

		System.out.println("Da skal vi pugge " + temaEase + ". Vi har " + ord.size() + " ord i listen vår!\n");

		int hints = 0;
		int forsok = 0;

		long startTid = System.currentTimeMillis();

		while(true) {
			System.out.println("Ord du har klart til nå:");

			// Skriver hvilke ord du har fått til
			int klart = 0;
			for (String ordet : ord.keySet())
				if(ord.get(ordet)) {
					System.out.println(" - " + toProperCase(ordet));
					klart ++;
				}

			// Skriver ut status
			if(klart == ord.size()) {
				System.out.println("\nGrattis! Det gikk fint. \"Bare\" " + hints + " hint og " +
						forsok + " forsøk i løpet av " + (int)((System.currentTimeMillis() - startTid)/1000) +
						" sekunder.");
				break;
			}
			else
				System.out.println("\nDu har klart " + klart + " av " + ord.size() + "\n");

			// input
			System.out.print("$ ");
			String linje = inn.nextLine().toLowerCase();

			// Om det er en kommando
			if(linje.equals("/h")) {
				for (String ordet : ord.keySet()) {
					if(!ord.get(ordet)) {
						int start = (int)(Math.random()*(ordet.length()-1));
						int stopp = (int)(Math.random()*(ordet.length()-start)) + start+1;
						System.out.println(ordet.substring(start, stopp));
						hints++;
						break;
					}
				}
				continue;
			}
			else if(linje.equals("/q"))
				break;

			// Riktig eller galt
			if(ord.get(linje) != null)
				ord.put(linje, true);
			else
				System.out.println("Fant ikke den...");

			forsok++;

		}
	}
	private static String toProperCase(String inputString) {
		StringBuilder ff = new StringBuilder();

		for(String f: inputString.split(" ")) {
			if(ff.length()>0)
				ff.append(" ");

			ff.append(f.substring(0,1).toUpperCase()).append(f.substring(1,f.length()).toLowerCase());
		}

		return ff.toString();
	}

	private static HashMap<string,Boolean> getWords(String filename) throws FileNotFoundException {

		Scanner s = new Scanner(new File(filename));
		Map<string,Boolean>  ord  = new HashMap<string,Boolean>();

		// Leser inn ord. Et per linje
		while(s.hasNextLine()) {
			ord.put(s.nextLine().toLowerCase().trim(), false);
		}
		return (HashMap<string, Boolean>) ord;

	}

}
</pre>


<p>Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-in-python/' rel='bookmark' title='Permanent Link: Simple quiz-program in Python'>Simple quiz-program in Python</a></li>
<li><a href='http://josteinb.com/2009/03/prepared-statements-in-java/' rel='bookmark' title='Permanent Link: Prepared Statements in Java'>Prepared Statements in Java</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2009/05/simple-quiz-program-written-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prepared Statements in Java</title>
		<link>http://josteinb.com/2009/03/prepared-statements-in-java/</link>
		<comments>http://josteinb.com/2009/03/prepared-statements-in-java/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 13:24:08 +0000</pubDate>
		<dc:creator>Jostein</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[prepared statements]]></category>

		<guid isPermaLink="false">http://josteinb.com/?p=13</guid>
		<description><![CDATA[Her er den fantastisk lærerike videoen til Tobias som jeg lovte å legge ut på siden min, etter at han maste så lenge om det. Related posts:Simple quiz-program written in Java


Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-written-in-java/' rel='bookmark' title='Permanent Link: Simple quiz-program written in Java'>Simple quiz-program written in Java</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Her er den fantastisk lærerike videoen til Tobias som jeg lovte å legge ut på siden min, etter at han maste så lenge om det.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/tlvE_ETWTGU" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/tlvE_ETWTGU"></embed></object></p>


<p>Related posts:<ol><li><a href='http://josteinb.com/2009/05/simple-quiz-program-written-in-java/' rel='bookmark' title='Permanent Link: Simple quiz-program written in Java'>Simple quiz-program written in Java</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://josteinb.com/2009/03/prepared-statements-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
