<?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>Conor's Blog &#187; Scratch</title>
	<atom:link href="http://blog.macaoidh.name/tag/scratch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.macaoidh.name</link>
	<description>PHP, Music, Linux</description>
	<lastBuildDate>Mon, 05 Jul 2010 13:25:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Java &#8211; Calculate Taxi Fares</title>
		<link>http://blog.macaoidh.name/2009/12/02/java-calculate-taxi-fares/</link>
		<comments>http://blog.macaoidh.name/2009/12/02/java-calculate-taxi-fares/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 00:21:25 +0000</pubDate>
		<dc:creator>Conor</dc:creator>
				<category><![CDATA[College]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fare]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Scratch]]></category>
		<category><![CDATA[taxi]]></category>

		<guid isPermaLink="false">http://blog.macaoidh.name/?p=281</guid>
		<description><![CDATA[This week my ICSP assignment was to calculate taxi fares. The task was: Using the fare table write a program that calculates the fares and test if it is correct. Upload your .java or your Scratch file. A template file for java will be provided. (Hint, only the boundary values needs to be tested. The [...]]]></description>
			<content:encoded><![CDATA[<p>This week my ICSP assignment was to calculate taxi fares. The task was:</p>
<blockquote><p>Using the fare table write a program that calculates the fares and test if it is correct. Upload your .java or your Scratch file. A template file for java will be provided. (Hint, only the boundary values needs to be tested. The fare table is also presented in the slides. The compile command for java should be &#8220;javac TaxiRide.java&#8221;)</p>
<table border="0">
<tbody>
<tr>
<th colspan="2">Fare table</th>
</tr>
<tr>
<th>Distance (km)</th>
<th>Cost (€)</th>
</tr>
<tr>
<td>&gt;50</td>
<td>30</td>
</tr>
<tr>
<td>50-100</td>
<td>25, plus 9 for each km &gt; 50</td>
</tr>
<tr>
<td>100 &#8211; 2000</td>
<td>190, plus 8 for each km &gt; 100</td>
</tr>
<tr>
<td>&gt; 2000</td>
<td>1800</td>
</tr>
</tbody>
</table>
</blockquote>
<p>It wasn&#8217;t the hardest task. The only thing that confused me was the Java switch syntax. In PHP you can have conditions in a switch statement such as:</p>
<pre class="brush:php">
&lt;?php
switch($num){
        case ($num&lt;10):
                // blah
        break;
        case ($num&lt;100):
                // blah
        break;
        default:
                //blah
?&gt;
</pre>
<p>I couldn&#8217;t get Java to accept anything other than a value for the variable bring switched. So I did it the old-fashioned way! My code is below&#8230;</p>
<pre class="brush:java">
public class TaxiRide{
        public int distance=0;

        public TaxiRide(String arg){
                try{
                        int distance=Integer.parseInt(arg);
                        this.distance=distance;
                }
                catch(NumberFormatException e){
                        System.err.println("Arguement must be an integer representing the distance traveled");
                        System.exit(1);
                }
        }

        public int calculateFare(){
                int distance=this.distance;
                int fare=0;
                int i=0;
                if(distance&lt;50){
                        return 30;
                }
                if(distance%lt;100){
                        fare=25;
                        distance-=50;
                        for(i=0;i&lt;distance;i++){
                                fare+=9;
                        }
                        return fare;
                }
                if(distance&lt;2000){
                        fare=190;
                        distance-=100;
                        for(i=0;i&lt;distance;i++){
                                fare+=8;
                        }
                        return fare;
                }
                return 1800;
        }

        public static void main(String[] args){
                TaxiRide taxiRide = new TaxiRide(args[0]);
                int fare=taxiRide.calculateFare();
                System.out.println("The fare is: "+fare+" euro for traveling "+taxiRide.distance+"kM\n Thank you\n");
        }
}
</pre>
<p>I feel i am learning a lot from this course. Lately I have been experimenting in a few different languages. I added a bit to the Scratch Linux installer, written in Perl, so that it added an icon in the applications menu during installation. I&#8217;ve also been messing around with bash, trying to automate some of my most common commands&#8230; was thinking of writing a small bash script that backed up my data when my external hard drive is plugged in, similar to Time Machine on OSX.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaoidh.name/2009/12/02/java-calculate-taxi-fares/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICSP Week One Assignment</title>
		<link>http://blog.macaoidh.name/2009/10/25/icsp-week-one-assignment/</link>
		<comments>http://blog.macaoidh.name/2009/10/25/icsp-week-one-assignment/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 20:38:05 +0000</pubDate>
		<dc:creator>Conor</dc:creator>
				<category><![CDATA[College]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[caputre the flag]]></category>
		<category><![CDATA[icsp]]></category>
		<category><![CDATA[Scratch]]></category>

		<guid isPermaLink="false">http://blog.macaoidh.name/?p=250</guid>
		<description><![CDATA[I started a course in UCD last week called &#8220;Introduction to Computer Science and Programing&#8221;, or ICSP. It&#8217;s gonna be going on for three months and then I will have a big exam which I will probably fail! The whole course centers around the use of Java, I&#8217;m not sure yet if we are going [...]]]></description>
			<content:encoded><![CDATA[<p>I started a course in UCD last week called &#8220;Introduction to Computer Science and Programing&#8221;, or <a href="http://www.csi.ucd.ie/content/introduction-computer-science-and-programming-icsp2009">ICSP</a>. It&#8217;s gonna be going on for three months and then I will have a big exam which I will probably fail!</p>
<p>The whole course centers around the use of Java, I&#8217;m not sure yet if we are going to be using anything else. We haven&#8217;t actually even started with Java yet, but we are using this program called <a href="http://scratch.mit.edu/">Scratch</a> to program our Java for us! I wouldn&#8217;t say that it is the Dream-weaver of Java, far from it. In fact I think that it is a great method of getting into Java. It has a set of preconfigured code which you can arrange into blocks, which then run &#8211; quite similar to the source of Java actually except simplified. It also eliminates the need for compiling.</p>
<p>Last week I went to my first &#8220;lecture&#8221; which was good enough, but I learned something valuable that day; computer hardware is not the road that I want to go down! I didn&#8217;t really enjoy the hardware aspect of the day but when it came to the Scratch lessons I was flying! For our first assignment we had to write a game in Scratch, which is essentially it&#8217;s own unique programing language. The game is called &#8220;Capture the Flag&#8221;. I was actually flat out all week and didn&#8217;t get a chance to start work on it until today, which is coincidentally the deadline for it&#8217;s completion! I spent about three hours making the game, here&#8217;s the manual and the game:</p>
<h3>Capture The Flag</h3>
<p><strong>Overview</strong><br />
Capture the flag is a simple two player game which involves stealing the flag from the opposite colours corner.</p>
<p><strong>Controls</strong><br />
Blue Player<br />
Up Arrow Key = Move Up<br />
Down Arrow Key = Move Down<br />
Left Arrow Key = Move Left<br />
Right Arrow Key = Move Right</p>
<p>Red Player<br />
W Key = Move Up<br />
S Key = Move Down<br />
A Key = Move Left<br />
D Key = Move Right</p>
<p><strong>Rules</strong><br />
To gain a point a player must capture the opposite colour flag and return it to their base (the starting point).</p>
<p>If a player is in possession of a flag and his opponent touches him the flag is returned to it&#8217;s base and the player to his base.</p>
<p>To win a player must gain three points.</p>
<p><strong>Faults</strong><br />
The one fault with the game is that, at least on my computer, when one player is using the keyboard to move the other player cannot move simultaneously. Although this is a fault it does also make the game a bit more interesting because the players have to fight even to move!</p>
<p><applet id='ProjectApplet' style='display:block' code='ScratchApplet' codebase='http://scratch.mit.edu/static/misc' archive='ScratchApplet.jar' height='387' width='482'>
<param name='project' value='../../static/projects/ConorMacAoidh/732336.sb'></param></applet> <a href='http://scratch.mit.edu/projects/ConorMacAoidh/732336'>Learn more about this project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaoidh.name/2009/10/25/icsp-week-one-assignment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Siopa Geansaí</title>
		<link>http://blog.macaoidh.name/2008/11/16/siopa-geansai/</link>
		<comments>http://blog.macaoidh.name/2008/11/16/siopa-geansai/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 21:43:24 +0000</pubDate>
		<dc:creator>Conor</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Web Projects]]></category>
		<category><![CDATA[blue jumper]]></category>
		<category><![CDATA[geansai gorm]]></category>
		<category><![CDATA[Scratch]]></category>
		<category><![CDATA[SEO competition]]></category>
		<category><![CDATA[Siopa Geansaí]]></category>

		<guid isPermaLink="false">http://macaoidh.name/?p=43</guid>
		<description><![CDATA[I started and finished work on a computer game today. Gavin Mc Bride handed me a copy of scratch the other day and I decided to have a go! Scratch is a program based on Java, at least it has the same structure, but a nice graphical interface. The game called &#8220;Siopa Geansaí&#8221; is located [...]]]></description>
			<content:encoded><![CDATA[<p>I started and finished work on a computer game today. <a href="http://scratch.mit.edu/users/gmcb1991">Gavin Mc Bride</a> handed me a copy of <a href="http://scratch.mit.edu">scratch</a> the other day and I decided to have a go! Scratch is a program based on <a href="http://www.java.com">Java</a>, at least it has the same structure, but a nice graphical interface.</p>
<p>The game called &#8220;Siopa Geansaí&#8221; is located <a href="http://macaoidh.name/index.php/about/">here.</a> To be honest it is pretty crap but it was good enough crac making it. I had some <a href="http://scratch.mit.edu/forums/viewtopic.php?id=11748">display problems</a> which I intent to fix (I am waiting for a response from the Scratch Forum), but besides that its a pretty simple game. It is set in a clothes shop &#8211; i know this may seem weird but it is explained below. The objective of the game is to pick the correct colour of Geansaí, if you do so you will win! As i said before simple!</p>
<p>You can use the arrow keys to move the Cat who changes colour when you put diferent Geansaí&#8217;s on him. There is a <a href="http://macaoidh.name/geansaigorm.jpg">Geansaí Gorm</a>, a Geansaí Glás and a Geansaí Dearg. Press the Enter/Return button to restart the game. Bring the geansaí to the check out to finish, that is where the <a href="http://scratch.mit.edu/forums/viewtopic.php?id=11748">display problems</a> are happening&#8230; try to ignore them! <img src='http://blog.macaoidh.name/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>The game is called &#8220;Siopa Geansaí&#8221; after the <a href="http://www.mulley.net/2008/10/28/mirror-mirror-on-the-wall-whos-the-greatest-seo-of-them-all/">Geansaí Gorm SEO Competition</a> which basically requires its participants to reach number one on the Google search results for &#8220;geansaí gorm&#8221; without having those words in the domain name. I couldn&#8217;t think of anything else to make a game about so I made it about this!!</p>
<p>Anyway enjoy the game, you can get back to me with feed back if you want but bear in mind that I know its terrible! <img src='http://blog.macaoidh.name/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Oh yeah and</p>
<p><span style="background-color:blue;color:#fff;padding:3px;font-size:20px;">GEANSAÍ GORM GEANSAÍ GORM GEANSAÍ GORM</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaoidh.name/2008/11/16/siopa-geansai/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
