<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9107963745788914426</id><updated>2012-02-12T18:00:00.533-05:00</updated><title type='text'>CSE 1030 Notes</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3829027733556614438</id><published>2008-03-11T17:50:00.001-05:00</published><updated>2008-03-11T17:50:36.696-05:00</updated><title type='text'>CSE 2031 Lecture 15</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Man ulimit | col 0b &amp;gt; foo.mantxt&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Filesystem&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Filesystem is an organized structure consisting of many files and / or directories&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A file is a stream of bytes&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Stores data&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Has a name&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Usually on disk or some other storage medium&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;A directory is a special file in the filesystem which contains files and other directories&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Unix filesystem&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Bin&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Usr&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Etc&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Users&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Admin&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;John &lt;br /&gt;&lt;/li&gt;&lt;li&gt;steve&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Staff&lt;br /&gt;&lt;/li&gt;&lt;li&gt;student&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;lib&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;drwx------ &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;read write execute &lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;d = filetype&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;d for directory&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;a normal file would have a – where the d is&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%ln marks cpOfMarks&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Creates a new link to marks&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Puts in a new name associated with the same inode number&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style='margin-left: 72pt'&gt;&lt;table border='0' style='border-collapse:collapse'&gt;&lt;colgroup&gt;&lt;col style='width:268px'/&gt;&lt;col style='width:275px'/&gt;&lt;/colgroup&gt;&lt;tbody valign='top'&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;Inode &lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;Name&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;1042&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;Temp&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;3784&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;Prog.c&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;4798&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;Marks&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;4798&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;ul&gt;&lt;li&gt;cpOfMarks&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;you need links if you have a file on another partition&lt;br /&gt;&lt;/li&gt;&lt;li&gt;pwd shows the current working directory&lt;br /&gt;&lt;/li&gt;&lt;li&gt;cd changes current directory&lt;br /&gt;&lt;/li&gt;&lt;li&gt;a path name is a reference to something in the filesystem&lt;br /&gt;&lt;/li&gt;&lt;li&gt;a path name specifies the set of directories you have to pass through to find a file&lt;br /&gt;&lt;/li&gt;&lt;li&gt;directory names are separated by "/" in Unix&lt;br /&gt;&lt;/li&gt;&lt;li&gt;special elements : "." And ".."&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"." Means "the current directory"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;".." means "the parent directory"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;/dec/tty – the terminal you are using&lt;br /&gt;&lt;/li&gt;&lt;li&gt;/dev / zero – an input stream which returns an edless stream of null bytes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;ls day?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Ls –ld day?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Ls –ld day1 day2 day3 day4 day5&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The ? goes thru all the files that say day&lt;br /&gt;&lt;/li&gt;&lt;li&gt;And then wildcards the rest of the names&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3829027733556614438?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3829027733556614438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3829027733556614438' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3829027733556614438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3829027733556614438'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/03/cse-2031-lecture-15.html' title='CSE 2031 Lecture 15'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4002385014292236033</id><published>2008-03-06T18:47:00.001-05:00</published><updated>2008-03-06T18:47:13.630-05:00</updated><title type='text'>2031 Lecture 14</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Check your assignment 1 q2.c for 'ERANGE' without this it is wrong apparently&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Fork&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Exec&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Open&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Close&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Dup/dup2&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Lseek&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Read&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Write&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Pipe&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Sets up a pip&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Writes to this end &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt;   |===========|   &lt;span style='font-family:Wingdings'&gt;ß&lt;/span&gt;reads from this end&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;pipe( &lt;em&gt;an array&lt;/em&gt; ) &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;int fd[2]&lt;br /&gt;&lt;/li&gt;&lt;li&gt;pipe(fd)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;fd[0] reads from the pipe&lt;br /&gt;&lt;/li&gt;&lt;li&gt;fd[1] writes to the pipe&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;										&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;#include &amp;lt;&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;#include &amp;lt;&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;#include &amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; main(&lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;void&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;{&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; fd[2];&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    pipe(fd); &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* should check return value but in this example we are not*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;switch&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;(fork())&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;case&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; -1:&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    perror (&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"Bad fork()"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    exit(1);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;case&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; 0:&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    execlp(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"who"&lt;/span&gt;&lt;span style='color:black'&gt;, &lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"who"&lt;/span&gt;&lt;span style='color:black'&gt;, NULL); &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;// first who is the command second is the argument vector&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    fprintf(stderr, &lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"should not get this far: bad exec"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    exit(1);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;default&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;:&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;switch&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;(fork())&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;case&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; -1:&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        perror (&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"Bad fork()"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        exit(1);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;case&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; 0:&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        close(fd[0]);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        dup2(fd[1], 1); &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/*file descriptor you want to duplicate, and file descriptor you want to duplicate it to*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        close(fd[1]); &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;// fd will now write into the pipe&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;default&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;: &lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        wait((&lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; *)0);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    wait((&lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; *)0);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    exit(0);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;}&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/*wthin a program we want to write a program we are going to open a file called temp and we will write printf statements and they will go into temp instead of a stream, there are&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;two ways to do this, one way is you can open a file called temp &lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;write(fd, ....);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;or&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;dup2(fd, 1) fd , 1 == standard output&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;any statement after this will print to fd instead of stdio&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;after this we can say close(fd); and this will still write to that file.. you do not get stdio back.&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;-----------------------&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;assignment q2.c&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;------------------------&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;illegal input if it doesn't take 2 ints or line is too long&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;#include &amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;#include &amp;lt;limits.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;#include &amp;lt;errno.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;void finishLine(FILE * fp, char * buf, size_t bufSize);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;int main(void)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;{&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;a buffer to hold line read in. &lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;add 2 for '\n; the '\0' added by fgets&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt; */&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;char&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; buf[MAX_LENGTH + 2];&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;long&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; n1, n2;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;char&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; * p;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;char&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; x[1];&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;printf("%1d\n", LONG_MAX):&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;printf("%1d\n", LONG_MIN):&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/* main loop reads a line at a time */&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;while&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; ((p=fgets(buf, sizeof(buf), stdin)) != NULL)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;{&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* errno may have been set on previous iteration.*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    errno = 0;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;check whether whole line read in.&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;if not line was too long. &lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;     */&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; (strchr(p, &lt;/span&gt;&lt;span style='color:#2a00ff'&gt;'\n'&lt;/span&gt;&lt;span style='color:black'&gt; == NULL %% strlen(p) &amp;gt; 50)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/*line too long.*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/*output message */&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        printf(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"illegal input\n"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* read and ignore rest of line*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        finishLine(stdin, buf, sizeof(buf));&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* get next line if one exists*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* if we reach here, line is not too long */&lt;/span&gt;&lt;span style='color:black'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* read from the line now stored in the buffer. &lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;reading into dumm x detects extra tokens on 1&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;we expect exactly 2 interger tokens.&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;note: in sscanf, the ...%1x... is one x, not..&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;if (sscanf(buf, "%1d %1d %1s" , &amp;amp;n1, &amp;amp;n2, x) != 2) /* the scan f returns the number of conversions*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        printf(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"illegal input \n"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* if we readch here, input consists of exactly 2 integers*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/*&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;check fo roverflow or underflow in n1 and n2. note that we'll have to read n1 and n2 again&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:#3f7f5f'&gt;     */&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    n1 = strtol(buf, &amp;amp;p, 10);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; (n1 == LONG_MAX &amp;amp;&amp;amp; errno == ERANGE)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        print(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"overflow\n"&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; (n1 == LONG_MIN &amp;amp;&amp;amp; errno == ERANGE)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;    {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        printf(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"underflow\n"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        n2 = sscanf(p, &lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"%1d"&lt;/span&gt;&lt;span style='color:black'&gt;, &amp;amp;n2);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        n2 = strtol(p, &amp;amp;p, 10);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; (n2 == LONG_MAX &amp;amp;&amp;amp; errno == ERANGE)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            printf(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"overflow\n"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt; (n2 == LONG_MIN %% errno == ERANGE)&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        {&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            printf(&lt;/span&gt;&lt;span style='color:#2a00ff'&gt;"underflow\n"&lt;/span&gt;&lt;span style='color:black'&gt;);&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;            &lt;/span&gt;&lt;span style='color:#7f0055'&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;/span&gt;&lt;span style='color:black'&gt;;&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        }&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* if we reach here both ints are legal and there is no other input other than 2 ints which is what we want*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;span style='color:black'&gt;        &lt;/span&gt;&lt;span style='color:#3f7f5f'&gt;/* strtol stops when it gets to something that isn't a digit, if what it reads is larger than long max it will return long max and set errno*/&lt;/span&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Courier New; font-size:10pt'&gt;&lt;br /&gt;				&lt;/span&gt; &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4002385014292236033?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4002385014292236033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4002385014292236033' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4002385014292236033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4002385014292236033'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/03/2031-lecture-14.html' title='2031 Lecture 14'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3139254986244388480</id><published>2008-03-04T18:44:00.001-05:00</published><updated>2008-03-04T18:44:54.012-05:00</updated><title type='text'>CSE 2031 Lecture 13</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;fork()&lt;br /&gt;&lt;/p&gt;&lt;p&gt;getpid() // get process ID&lt;br /&gt;&lt;/p&gt;&lt;p&gt;getppid() // get parent process ID&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;fork is a system call w/ no arguments but it returns a value&lt;br /&gt;&lt;/p&gt;&lt;p&gt;the parent and the child see different return values&lt;br /&gt;&lt;/p&gt;&lt;p&gt;the newly created child see's return value 0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;the parent that called fork see's a nonzero return value, namely the ppid of the newly created child&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;a child finds a parents process ID by calling getppid()&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;when a child terminates, OS saves PID, exit status, cpu time ... of child&lt;br /&gt;&lt;/p&gt;&lt;p&gt;and passes this to the parent when parent calls wait() or waitpid&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;until then the child is a 'zombie'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;the OS can't free up the resources for the child until the parent waits on the child&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if the parent finishes before the child, then the child is reparented&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    wait &lt;br /&gt;&lt;/p&gt;&lt;p&gt;            - block until first child finishes&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    waitpid&lt;br /&gt;&lt;/p&gt;&lt;p&gt;        - block&lt;br /&gt;&lt;/p&gt;&lt;p&gt;        -specify which child to wait for&lt;br /&gt;&lt;/p&gt;&lt;p&gt;pid of child &amp;lt;- wait(int*)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int status&lt;br /&gt;&lt;/p&gt;&lt;p&gt;wait(&amp;amp;status)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;%a.out&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    - what we have here is the shell foks off a child and waits for the child to return&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    child - executes a.out&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    once done the parent outputs the prompt and waits for another command to be inputted&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if %a.out &amp;amp;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -the shell doesn't wait. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;-----------------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;sys/wait.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stlib.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#define MAX 10&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main(void)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;int i;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fork();&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fork();&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf("Hello\n");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;return 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;// prints 4 'Hello" lines&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-----------------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;sys/wait.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stlib.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#define MAX 10&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main(void)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;int i;&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;switch(fork())&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;case -1: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;    perror("Bad fork");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    exit(1)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;case 0:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    /* CHILD */&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    for (i=0; i &amp;lt; MAX; i++)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    {&lt;br /&gt;&lt;/p&gt;&lt;p&gt;        printf("CHILD\n");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    }break;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;default:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    /* PARENT */&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    for(i = 0; i &amp;lt; MAX; i++)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    {&lt;br /&gt;&lt;/p&gt;&lt;p&gt;        printf("\tPARENT\n");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    }&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    printf("pid = %d\n", getpid());&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    printf("ppid = %d\n", getppid());&lt;br /&gt;&lt;/p&gt;&lt;p&gt;return 0;    &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;/*prints CHILD 10 times, pid = 2153, ppid = 2152, prints PARENT 10 times then , pid = 2255, ppid = 27289&lt;br /&gt;&lt;/p&gt;&lt;p&gt;eventually the parent executes before the child because it is left to the OS to decide the PPID*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/* if wait((int * ) 0);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;was typed after /*PARENT*/ it will always print CHILD first*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;along with fork() there is exec()&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;%a.out hello there world becomes&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;argv -&amp;gt; -&amp;gt; a.out&lt;br /&gt;&lt;/p&gt;&lt;p&gt;           -&amp;gt;hello&lt;br /&gt;&lt;/p&gt;&lt;p&gt;           -&amp;gt;there&lt;br /&gt;&lt;/p&gt;&lt;p&gt;           -&amp;gt;world&lt;br /&gt;&lt;/p&gt;&lt;p&gt;           -&amp;gt;null&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;-------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;execlp("cat", "-n", "temp", NULL);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;"cat"&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3139254986244388480?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3139254986244388480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3139254986244388480' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3139254986244388480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3139254986244388480'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/03/cse-2031-lecture-13.html' title='CSE 2031 Lecture 13'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6578449273074822813</id><published>2008-02-21T18:44:00.001-05:00</published><updated>2008-02-21T18:44:16.999-05:00</updated><title type='text'>CSE2031 lecture 12</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;SystemCalls&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Check out these books&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Stevens Advanced Programming in the unix Environment&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Robins&amp;amp;Robins – unix systems programming&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Processes&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Fork&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Exec….&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Files&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Open&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Close&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Read&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Write&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Lseek&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Dup&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Dup2&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border='0' style='border-collapse:collapse'&gt;&lt;colgroup&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;/colgroup&gt;&lt;tbody valign='top'&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;PerProcess file Descriptor table&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;System wide open file table&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;I-Nodes&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;File descriptors&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Flags&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Disk / device&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;0&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Offset&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;1&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;To i-node&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;2&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;..&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Write(fd,buf,50)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Fd &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;File descriptor&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Buf&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Void* char&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;50&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;#bytes&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Write(fd,"Hello",6)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If this was typed after the first line there would be an offset of 56&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Lseek&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Lseek(fd,offset,WHENCE)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Fd&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;File descriptor&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Offset&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;WHENCE&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;SEEK_SET&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SEEK_CUR&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SEEK_END&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Dup&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Duplicates a file descriptor using another file descriptor&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Int dup(int oldfd);&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Int dup2(int oldfd, int newfd)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Why would you want to do that?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Because you would never want to do this&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Dup2(fd,1);&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;First argument is one you want copied&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Second is what you want it copied on &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Close(fd);&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Printf("hello\n";&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This would write at a file temp&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;int a[15]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;int (*a)[15] /** a is a pointer to an array of 15 ints**/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;int fd&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fd = open("temp", _|_|_, 0660)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*for the last input '0660' there should always be a leading 0 because it is an octal*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*_| represents space for flags*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#define    O_WRONLY    1&amp;lt;&amp;lt;4&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    O_TRUNK    1&amp;lt;&amp;lt;2&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fd = open("temp", ..flag..)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;write(fd,...)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;close(fd)x&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;always check the return value from a system acall&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;if((fd = open("temp", ..flags..))&amp;lt;0){perror("...."); exit(1)}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;for every file there exists an 'I-Node"&lt;br /&gt;&lt;/p&gt;&lt;p&gt;along with an I-Node there is a system-wide openfiletable&lt;br /&gt;&lt;/p&gt;&lt;p&gt;and with that there is a perprocess file descriptor table&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6578449273074822813?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6578449273074822813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6578449273074822813' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6578449273074822813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6578449273074822813'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/02/cse2031-lecture-12.html' title='CSE2031 lecture 12'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-1087979497792327623</id><published>2008-02-19T18:46:00.001-05:00</published><updated>2008-02-19T18:46:23.629-05:00</updated><title type='text'>CSE2031 Lecture 11</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;    #include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;int main(int argc, char* argv[])&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;return 0; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;-------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;command line arguments&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;args can be accessed just like a normal allocated array &lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf("%s\n", argx[2]);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;-------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;bit operations&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;used to be used to pack and unpack things into small space, but space is cheap now. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;operating on bits&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;logical operators (unary) bitwise complement ~&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    bitwise AND    &amp;amp;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    bitwise XOR    `&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    bitwise OR    |&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;shift operators&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    left shift        &amp;lt;&amp;lt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    right shift        &amp;gt;&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;do not confuse &amp;amp; with &amp;amp;&amp;amp;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;            or | with || &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;right shift shifts in ?? on left end&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for unsigned, zeros shifted on the left end&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for signed, machine dependent&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -shift in zeros&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -shit in sign bits&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int    a=1 &amp;lt;&amp;lt; 31; /* shift 1 to high bit*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;unsinged    b = 1 &amp;lt;&amp;lt; 31;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;expn        representation&lt;br /&gt;&lt;/p&gt;&lt;p&gt;a        10000000 00000000 00000000 00000000&lt;br /&gt;&lt;/p&gt;&lt;p&gt;a &amp;gt;&amp;gt; 3        11110000 00000000 00000000 00000000&lt;br /&gt;&lt;/p&gt;&lt;p&gt;b        10000000 00000000 00000000 00000000&lt;br /&gt;&lt;/p&gt;&lt;p&gt;b &amp;gt;&amp;gt; 3        00010000 00000000 00000000 00000000&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;to turn bits on , use OR and 1's&lt;br /&gt;&lt;/p&gt;&lt;p&gt;v  |  3 &amp;lt;&amp;lt; 2&lt;br /&gt;&lt;/p&gt;&lt;p&gt;v  |  00000000 00001100&lt;br /&gt;&lt;/p&gt;&lt;p&gt;has 3rd and 4th bit on, others as in v&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;to turn bits off, use AND and 0's&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    v  &amp;amp;  ~(3&amp;lt;&amp;lt;2)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    v  &amp;amp;  11111111 11110011&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    has 3rd and 4th bit off, others as in v&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;masks&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    -a string of bits used to extract bits from another expression&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -to find value of a particular bit in an expression&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    - use a mask that is 1 at that bit and 0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;otherwise&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    1 &amp;lt;&amp;lt; 2 as mask to query 3rd bit in v&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    (v &amp;amp; (1 &amp;lt;&amp;lt; 2) ) ? 1 : 0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    has value 1 if 3rd bit in v is 1 and 0 otherwise&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;bit representation of 255&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    00000000 00000000 00000000 11111111&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    &lt;br /&gt;&lt;/p&gt;&lt;p&gt;    0    --&amp;gt; all 0's&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    ~0     --&amp;gt; all 1's&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    ~0&amp;lt;&amp;lt;k     --&amp;gt; 111...11 000..0 &lt;br /&gt;&lt;/p&gt;&lt;p&gt;~0(~0&amp;lt;&amp;lt;k)&amp;lt;&amp;lt;r     --&amp;gt; 000..0 11111111 000.00&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-1087979497792327623?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/1087979497792327623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=1087979497792327623' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1087979497792327623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1087979497792327623'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/02/cse2031-lecture-11.html' title='CSE2031 Lecture 11'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5661533489460614318</id><published>2008-02-07T18:41:00.001-05:00</published><updated>2008-02-07T18:41:01.652-05:00</updated><title type='text'>CSE2031 Lecture 10</title><content type='html'>&lt;span xmlns=''&gt;&lt;div&gt;&lt;table border='0' style='border-collapse:collapse'&gt;&lt;colgroup&gt;&lt;col style='width:160px'/&gt;&lt;col style='width:160px'/&gt;&lt;col style='width:160px'/&gt;&lt;col style='width:160px'/&gt;&lt;/colgroup&gt;&lt;tbody valign='top'&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Specifier&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Field type&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Converted using&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Arg is pointer to&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;d&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Integer (optionally signed)&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Strtol with base 10&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Int&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;hd&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Short int&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ld&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Long int&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;I&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Strtol with base = 0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Reads 045 as octal&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Ox92 as hexadecimal&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;hi&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Short&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;li&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Long&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;O&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Integer&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Strtoul base 8&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ho&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned short&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Lo&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned long&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;U&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Base 10&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Hu&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Lu&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;X&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Integer&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Strtoul base 16&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Does not accept AB&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Hx&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Lx&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;E&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Floating point input field&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Strtol&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Float&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;le&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Double&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Le&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;''&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Long double&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;fscanf&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-----------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;int fscanf(FILE*stream, const char * format, ...)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;scanf is like fscanf(stdin,...)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sscanf(const char* src, ...format...&lt;br /&gt;&lt;/p&gt;&lt;p&gt;return value = # of text fields converted to values that are stored&lt;br /&gt;&lt;/p&gt;&lt;p&gt;scanf("%d %f", &amp;amp;n,&amp;amp;x)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;return EOF if the function stops scanning&lt;br /&gt;&lt;/p&gt;&lt;p&gt;because the attempt to get next character it sets end of file or error indicator&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for stream ferror(fp), feof(fp)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;format string&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;can have white space&lt;br /&gt;&lt;/p&gt;&lt;p&gt;matches any amount of whitespace in the input&lt;br /&gt;&lt;/p&gt;&lt;p&gt;"%d&amp;lt;&amp;gt;%f&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;&amp;gt; represents a space&lt;br /&gt;&lt;/p&gt;&lt;p&gt;literal text&lt;br /&gt;&lt;/p&gt;&lt;p&gt;scan conversion specifier&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -like those from printf ( sort of )&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;conversion specifier&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-start w/ % sign&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-*assignment supression&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    looks like scanf(%d %*d %d &amp;amp;m)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-w field width&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-conversion specifier&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -give type of argument to expect&lt;br /&gt;&lt;/p&gt;&lt;p&gt;        -always a pointer to something&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -how to determind conversion field&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -how to convert value to store&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    &lt;br /&gt;&lt;/p&gt;&lt;p&gt;(a) scan set&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[     ]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;keep reading any of these characters (above)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{^     }&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Don't read these characters (above)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;b) otherwise (and usually)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    d&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    i&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    o    hl&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    u&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    x&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    X&lt;br /&gt;&lt;/p&gt;&lt;p&gt;d and i are different in scan f&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    eE&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    fF    lL&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    gG&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    c&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    s&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    n&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    p&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;-------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;%wc    w chars no '\0' appended        store arg char*&lt;br /&gt;&lt;/p&gt;&lt;p&gt;defaults to 1 for %c&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;%ws    w chars                charx then append '\0'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;default %s all of next token&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;scanf("%10c", buf)             reads first 10 chars even if it is whitespace&lt;br /&gt;&lt;/p&gt;&lt;p&gt;scanf("%10s", buf)            skips all the whitespace reads first 10 chars&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;char *p;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;strtol("    347atx  ", &amp;amp;p, 6);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//skips whitespace and reads legal digits in 'this' base (this being 6)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//returns 22 (3 sixes + 4) and pointer p points to the 7&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if value outside the range it will return LONG_MAX/ LONG_MIN  + set errno to ERANGE&lt;br /&gt;&lt;/p&gt;&lt;p&gt;0 &amp;lt;-- system call &lt;br /&gt;&lt;/p&gt;&lt;p&gt;-1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;x&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;file* &amp;lt;--Fopen&lt;br /&gt;&lt;/p&gt;&lt;p&gt;NULL&lt;br /&gt;&lt;/p&gt;&lt;p&gt;x&lt;br /&gt;&lt;/p&gt;&lt;p&gt;------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;perror("usermessage");            prints out "usermessage: system error messsage" error message corresponding to error number&lt;br /&gt;&lt;/p&gt;&lt;p&gt;strerror(errno)                 returns appropriate error string&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;            &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5661533489460614318?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5661533489460614318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5661533489460614318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5661533489460614318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5661533489460614318'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/02/cse2031-lecture-10.html' title='CSE2031 Lecture 10'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2279391982848068825</id><published>2008-02-05T18:44:00.001-05:00</published><updated>2008-02-05T18:44:42.290-05:00</updated><title type='text'>CSE 2031 Lecture 9</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Assignment FAQ&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Output files as they are read. For first question : instead of outputting palendromes output 'line is too long' after a certain length.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;file*  &lt;span style='font-family:Wingdings'&gt;ß&lt;/span&gt; fopen(…)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;file* fp;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fp = fopen("temp","a");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fprintf(fp,'%s\n", "Hello");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fclose(fp);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf == fprintf(stdout,…);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;"r+" opens a file for reading and writing&lt;br /&gt;&lt;/p&gt;&lt;p&gt;"w+" creates a file or truncates it if it exists and reads and writes to it&lt;br /&gt;&lt;/p&gt;&lt;p&gt;File descriptor talks to offset talks to inode &lt;br /&gt;&lt;/p&gt;&lt;p&gt;When you give a command like write you specify a file descriptor, where you find the data and how much you want to write&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A file is a sequence of bytes, &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Fseek, frewind, fsetpos are ways to specify the file pointer and where in the file you would like to go in the offset&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;States of a stream&lt;br/&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;ul style='margin-left: 72pt'&gt;&lt;li&gt;&lt;div&gt;Opened&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;If you write you go to .. &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Writing state&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If you continue writing you stay in the write state&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If you use seek or rewind you will go back to&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Opened state&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If you just finished writing then you read&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Error state&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If you read you go to &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Reading state&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If you continue reading you stay in the read state&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;I f you just finished reading then you write &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Error state&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Printf(format string; other args)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Format string&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Literal text&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Conversion specifier&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Printf("hello world \n");&lt;br /&gt;&lt;/li&gt;&lt;li&gt;^literal text&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Printf("n=%d\n", n);&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Literal text&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"n=" + "\n"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Conversion specifier&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"%d"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Other arguments&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"n"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Using print f&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A char and short is always converted to int&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A float is always converted to double&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Conversion specifier&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Starts with "%"&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;4 components (in order)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Flags&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Field width&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Precision&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Conversion specifier&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;first 3 are optional&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border='0' style='border-collapse:collapse'&gt;&lt;colgroup&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;/colgroup&gt;&lt;tbody valign='top'&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;d,i&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;[-]ddd      (where d are digits)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;u&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ddd&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;o&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ddd 0-7&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;x&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ddd 0-9 a-f&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;X&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Unsigned int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;ddd 0-9 A-F&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border='0' style='border-collapse:collapse'&gt;&lt;colgroup&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;col style='width:213px'/&gt;&lt;/colgroup&gt;&lt;tbody valign='top'&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;f&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Double&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  solid black 0.5pt; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;[-]ddd.ddd&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;E,e&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Double&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;[-]d.ddd e/E +/- dd&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;G,g&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Double&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;-4&amp;lt;= exponent &amp;lt;precision (life f or e,E&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;c&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Int&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Treats int as unsigned char&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Prints the character&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;S&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Char*&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Output chars from array up to '\0'&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;P&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Void*&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;System dependant&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Prints an address, usually in hexidecimal&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;N&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Int*&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Stores in variable; # of characters printed so far. No conversion&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid black 0.5pt; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;%&lt;/p&gt;&lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt; &lt;/td&gt;&lt;td style='padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid black 0.5pt; border-right:  solid black 0.5pt'&gt;&lt;p&gt;Writes a '%' sign&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Length specifier in conversion specifier&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;h,l,L&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;you can have the h in front on the integer conversion specifiers&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;conversion specifier applies to short int (unsigned short int)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;remember char / short args already promoted to int&lt;br /&gt;&lt;/li&gt;&lt;li&gt;convert arg to short before printing&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;the L,f,e,E,g,G conversion specifier applies to long double argument&lt;br /&gt;&lt;/li&gt;&lt;li&gt;do now use lowercase l or h with f,e,E,g,G&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;flags&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;field width&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;%5d&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Decimal no sign&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Field width of size 5&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%-d&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Fiend width 5&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;'-' is a flag&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Left jusitication&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%*d&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Take next arg as field width&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Scanf("%*lf, …)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;* in scanf  the * says read  a double from input&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Precision&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;After the period&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%.5d&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Min # digits to output, pad left w/ 0's&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%.5f&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;# of fraction digits &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%.5g&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Max # of significant digits&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&amp;amp;.5s&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Max # of characters to print from the string&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Flags&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;-&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Left justify&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;0&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Pads with 0's&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;+&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Forces explicit plus sign&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;' ' (space)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Use a space instead of plus sign in the output&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;#&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Changes conversions&lt;br /&gt;&lt;/li&gt;&lt;li&gt;0 &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; leading 0&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%#F&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The decimal sign is printed even if there is nothing after it&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2279391982848068825?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2279391982848068825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2279391982848068825' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2279391982848068825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2279391982848068825'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/02/cse-2031-lecture-9.html' title='CSE 2031 Lecture 9'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5675855355955532642</id><published>2008-02-05T11:17:00.001-05:00</published><updated>2008-02-05T11:17:37.884-05:00</updated><title type='text'>EATS 1011 Lecture 10</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Clouds&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;Nacreous clouds&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;A form of PSC (~10 microns)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Formed by waves over mountains&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Text and other locations: nacreous clouds&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;PSC&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Polar stratospheric clouds&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Located about 15-25km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Winter polar stratosphere is very cold 180-190 K&lt;br /&gt;&lt;/li&gt;&lt;li&gt;HNO&lt;sub&gt;3&lt;/sub&gt; and water form ice clouds&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Ice surfaces catalyse conversion of HCL to CL which attacks ozone and creates ozone hole&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Contains:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;H&lt;sub&gt;2&lt;/sub&gt;O, h2SO&lt;sub&gt;4&lt;/sub&gt;, HNO&lt;sub&gt;3&lt;/sub&gt;, HCL&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Noctilucent Clouds&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Only appear in polar regions&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Size ~.1 microns or smaller&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Very thin layer clouds: &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Hard to see over head&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Only visible at twilight or later w/ a long path for illumination&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;At the summer mesopause&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Very cold ~100-140 K &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;173 to 133 degrees celcius&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Frozen water&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Ccn probably meteoritic dust&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Wave structures revealed in ice formation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Can be warning of increased methane (CH&lt;sub&gt;4&lt;/sub&gt;)`&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Lapse Rates&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Environmental&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Γ&lt;sub&gt;e&lt;/sub&gt; environmental lapse rate&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;dT/dz = ΔT /ΔZ  = - Γ&lt;sub&gt;e&lt;/sub&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;&lt;div&gt;'dry' adiabatic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;g/C&lt;sub&gt;p&lt;/sub&gt; = Γ&lt;sub&gt;dry&lt;/sub&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;'moist' adiabatic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;g/C&lt;sub&gt;p&lt;/sub&gt; = Γ&lt;sub&gt;moise&lt;/sub&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Γ&lt;sub&gt;Moist&lt;/sub&gt; &amp;lt; Γ&lt;sub&gt;Dry&lt;/sub&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Depends on the planet and the major gas&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;AIR PARCEL(AP)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Think of an isolated unit of air maintaining its integrity&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This doesn't work for long because of exchange of molecules etc&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Lapse rate is how the temp is going to change in height&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A steep lapse rate means large temperature change&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Adiabatic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;No exchange of energy with outside&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Cooling&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Important in Cloud formation and rain&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mean global rate&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;~6.5 C/Km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Inversion, temperature increases with height&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Specific heat @ constant pressure C&lt;sub&gt;p&lt;/sub&gt; energy add to raise temp 1Celsius for 1kg @ constant pressure&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Specific heat @ constant Volume C&lt;sub&gt;v&lt;/sub&gt; energy add to raise temp 1Celsius for 1kg @ constant pressure&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;C&lt;sub&gt;p&lt;/sub&gt;(air) = 1007 J/kg/Kelvin&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For one Kg you have to have supply 1007 joules for 1 degree celcius difference&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;C&lt;sub&gt;v&lt;/sub&gt;(air) = 700 J/kg/Kelvin&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;− T2 ) / (Z2 – Z1) = (-g)/Cp&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Dry adiabatically&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;-(T&lt;sub&gt;1&lt;/sub&gt;MC&lt;sub&gt;p&lt;/sub&gt;) &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Extract heat&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;+  Mg(z&lt;sub&gt;2&lt;/sub&gt;-z&lt;sub&gt;1&lt;/sub&gt;)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Add potential energy&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;+ CpMT&lt;sub&gt;2&lt;/sub&gt;&lt;br /&gt;					&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Add heat&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5675855355955532642?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5675855355955532642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5675855355955532642' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5675855355955532642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5675855355955532642'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/02/eats-1011-lecture-10.html' title='EATS 1011 Lecture 10'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8498393871875298492</id><published>2008-01-31T18:47:00.001-05:00</published><updated>2008-01-31T18:47:32.226-05:00</updated><title type='text'>CSE2031 Lecture 8</title><content type='html'>&lt;span xmlns=''&gt;&lt;ul&gt;&lt;li&gt;When creating a struct no space is allocated&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;typedef&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Make a new type name&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Typedef double grade&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"grade" is now a new type&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;grade g1 = 3.5&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Grade can be used whenever double is used&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Typedef unsigned int size_t;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Typedef void (*_sighandler_t)(int)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Pointers to structs&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Structpoint p1;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Structpoint* pp;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;pp = &amp;amp;p1;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;the name of a struct is not a pointer to the beginning of the variable&lt;br /&gt;&lt;/li&gt;&lt;li&gt;p1.x = 9&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;*pp.x = 9 //doesn't work&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Because dot operator has precedence over *&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;(*pp).x = 9 &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;// will properly dereference the struct&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;pp&lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt;x = 9&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;same as (*pp).x =9 only this is proper&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;self referential structures&lt;br /&gt;&lt;/li&gt;&lt;li&gt;if you don't use malloc calloc etc it is put on the stack not the heap&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;look in back of the book under IO&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;c library IO(buffered)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;this is the buffer which input and output is written to&lt;br /&gt;&lt;/li&gt;&lt;li&gt;int getChar(void)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;int putchar(int)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;scanf &lt;br /&gt;&lt;/li&gt;&lt;li&gt;printf&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;file access&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;FILE&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;The way you create one is&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;FILE * fp&lt;br /&gt;&lt;/li&gt;&lt;li&gt;fp = fopen("filename", mode);&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;mode is &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;read write and append&lt;br /&gt;&lt;/li&gt;&lt;li&gt;a 2 character string&lt;br /&gt;&lt;/li&gt;&lt;li&gt;char*&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;instead of filename you can use&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"rb"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"wb"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Ab"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"rt"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"wt"&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"at"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;//creating a structpoint//&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;structpoint{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    int x;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    int y;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;    }&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;structpoint p1;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.x = 5;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.y = 6;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;or&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;structpoint p1 = {5,6};&lt;br /&gt;&lt;/p&gt;&lt;p&gt;----------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;or&lt;br /&gt;&lt;/p&gt;&lt;p&gt;structpoint{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int x;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int y;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.x = 5&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.y = 6;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//you can make a new struct doing it this way&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int x;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int y;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.x = 5;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p1.y = 6;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//cannot make a second struct doing it this way&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;typef unsigned int size_t;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;typedef void (*_sighandler_t)(int)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;typedef structpoint {&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int x;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int y;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;point;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*now "point" is the name of a type&lt;br /&gt;&lt;/p&gt;&lt;p&gt;* it can have pint p1;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*instead of structpoint p1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/* self referential structures*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct listNode{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int value;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct listNode* next;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct treeNode{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int value; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct treeNode* left;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct treeNode* right;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;or&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;typedef structTNode* TreePtr&lt;br /&gt;&lt;/p&gt;&lt;p&gt;typedef structTNode{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int value;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;TreePtr left;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;TreePtr right;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}TreeNode&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;-----------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;TreePtr root = (TreePtr)malloc(sizeof(TreeNode));         // - do not do this instead - sizeof(int) + 2*sizeof(TreePtr)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;root-&amp;gt;value = 5;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;root -&amp;gt; right = (TreePtr)malloc(sizeof(TreeNode));&lt;br /&gt;&lt;/p&gt;&lt;p&gt;root -&amp;gt; right -&amp;gt;value=2;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;root -&amp;gt; right-&amp;gt;right =null;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;root -&amp;gt; right -&amp;gt;left = null;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*creates a binaryTree with root starting point at 5 pointing to a 2 on its right side that has no strings after it*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct item{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;double price;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;char name[50];&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;item x1;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;strcpy(x1,name, "Notebook");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct item{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;double price;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;char* name; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;item x1; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;x1.name = "notebook";&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-----------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fprintf(fp,...);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fscanf(fp,...);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fclose(fp);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ferror(fp);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;intfeof(fp); //if you reached end of file on that file&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fflush(fp);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fseek(fp,...);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fsetpos(fp,...);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------buffered standard output under this line--&lt;br /&gt;&lt;/p&gt;&lt;p&gt;stdin&lt;br /&gt;&lt;/p&gt;&lt;p&gt;stdont&lt;br /&gt;&lt;/p&gt;&lt;p&gt;stderr&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---------unbuffered under this line---&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;STDIN_FILENO         0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;STDOUT_FILENO        1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;STDERR_FILENO        2&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main(void)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf("a");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;write(1, "X", 1);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;fprintf(stdout, "B");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;write (1,"Y", 1);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf("C");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;write(1, "Z\n", 2);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf("\n");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;return 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*output is &lt;br /&gt;&lt;/p&gt;&lt;p&gt;XYZ&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ABC&lt;br /&gt;&lt;/p&gt;&lt;p&gt;this is becuase it's buffered&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;                        &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8498393871875298492?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8498393871875298492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8498393871875298492' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8498393871875298492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8498393871875298492'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2031-lecture-8.html' title='CSE2031 Lecture 8'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3731659702277235788</id><published>2008-01-29T18:42:00.001-05:00</published><updated>2008-01-29T18:42:55.291-05:00</updated><title type='text'>CSE2031 Lecture 7</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;void* &lt;span style='font-family:Wingdings'&gt;ß&lt;/span&gt; malloc (int n)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int *p;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p = malloc (50 * sizeof(int));&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Or&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt; p = (int*) malloc(50*sizeof(int));&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if((p=malloc(..) ) == null)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;…exit(1)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;free(p); //deallocate this space;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;calloc enters 0's in memory for allocated space&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;go to man 3 malloc&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;talks about malloc calloc and realloc &lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;realloc &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;allows you to resize memory partition previously allocated&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;arrays in C don't know how long they are&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;int x     //declares an int&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int f(int a , double b)     // function that returns an int&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int *f(int a, double b)     //pointer to a unction that returns an int&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int (*f)(int a, double b  )//declares a function that takes parameters and returns an int&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int strCompare(const void *, const void *);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int intCompare(const void* p1, const void* p2);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int main(void)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;char* A[] = {"30","3","20","2","0","5","10","1","40","4", "5"};&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;    for (i = 0;i&amp;lt;11;i++)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;printf("%s ", A[i[);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;putchar('\n');&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;qsort(A, sizeof(A)/sizeof(char *), sizeof(char *), strCompare);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int strCompare(const void*p1,const void*p2)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int n = strcmp(*(char**)p1, *(char**)p2); //&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;if (n&amp;lt;0) return -1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;if (n&amp;gt;0) return 1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int intCompare(const void*p1, const void*p2)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int n1 = atoi(*(char**)p1);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;int n2 = atoi(*(char**)p2); // atoi casts string to integer&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;if (n1&amp;lt;n2) return -1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;if (n1&amp;gt;n2) return 1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;(A, ... , cmp)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;//int cmp(const void *p1, const void *p2)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;//{int n1 = &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;   int n2 = &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;   if(n1&amp;lt;n2) return -1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;   if(n1&amp;gt;n2) return 1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial; font-size:8pt'&gt;   return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;c struct&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;struct point {int x, int y};&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;point is the structure tag&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3731659702277235788?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3731659702277235788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3731659702277235788' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3731659702277235788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3731659702277235788'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2031-lecture-7.html' title='CSE2031 Lecture 7'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-588511889824137193</id><published>2008-01-29T14:16:00.001-05:00</published><updated>2008-01-29T14:16:10.366-05:00</updated><title type='text'>CSE2011 Lecture 8</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Loop invariants&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What is the loop invariant&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In general it is an extremely difficult question to answer. It contains the essential difficulty in programming&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Fundamentally it is the following&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;LI = totalWork = workToDo  + workDone&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Question a: does the loop terminate?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Question b: is the postcondition of OP true at loop end&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Loop Design&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Find the loop invariant&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;After consulting an oracle we have determined that the following is an appropriate loop invariant&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;This is the create part of programming&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Question 1 &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Make the loop invariant true at the start&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Question 2&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Is the loop invariant still true after operation 2 is executed?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;After operation2 show li first part is true&lt;br /&gt;&lt;/li&gt;&lt;li&gt;See effect of moving data from workToDo to workDone while maintaining th&lt;strong&gt;e invarian&lt;/strong&gt;t&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-588511889824137193?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/588511889824137193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=588511889824137193' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/588511889824137193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/588511889824137193'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2011-lecture-8.html' title='CSE2011 Lecture 8'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6315941109867119007</id><published>2008-01-29T11:14:00.001-05:00</published><updated>2008-01-29T11:14:13.077-05:00</updated><title type='text'>EATS1011 Lecture 8</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Clouds &lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Clouds to fall but then they fall into warmer air and evaporate&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;CCN: 100%&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Cloud condensation Nuclei (CCN)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Newton's first law&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The droplet of radius r&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The droplet's going down &lt;br /&gt;&lt;/li&gt;&lt;li&gt;And friction of particles in the air&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Eventually balance out &lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Friction force&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;6πR(eta) V&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Eta is viscosity (missing symbol)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Gravitational force&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;M*g&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;M ass of the droplet&lt;br /&gt;&lt;/li&gt;&lt;li&gt;G ravity&lt;br /&gt;&lt;/li&gt;&lt;li&gt;= 4/3πR&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;										&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;These two forces equal each other out&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Get formulas from website&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This only applies to 'small' droples (&amp;lt; 100microns)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Terminal Velocity&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;V&lt;sub&gt;T&lt;/sub&gt; = 6x10&lt;sup&gt;3&lt;/sup&gt; R(m) m/s    (R&amp;gt; 100 &lt;span style='font-family:Symbol'&gt;m&lt;/span&gt;m)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Condenstation -&amp;gt; growth &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1/R&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;1) collision and coalescence&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Warm&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;2) bergeon process&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Mixed phase clouds&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;(liquid water + ice)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The difference in vapour pressure drives the growth of the droplets&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Size spectrum&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1 micron -&amp;gt; 5 microns -&amp;gt; 10 microns – 15 microns – 50 microns&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The small ones fall slower than the large ones&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The large one sweep up the smaller ones under them&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Until the droplet gets even bigger and falls faster&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If there are enough small particles you can see how we get very large droplets&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6315941109867119007?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6315941109867119007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6315941109867119007' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6315941109867119007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6315941109867119007'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats1011-lecture-8.html' title='EATS1011 Lecture 8'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8575499339279246772</id><published>2008-01-24T18:51:00.001-05:00</published><updated>2008-01-24T18:51:24.776-05:00</updated><title type='text'>CSE 2031 Lecture 6</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Arrays and pointers&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;An array name by itself is&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An address&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A pointer value&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A pointer is&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A variable taking addresses as values&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;An array name is&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A particular fixed address&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Like a constant pointer&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;When an array is declared, the compiler allocates&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;A base address &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The address of element 0&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;And sufficient memory allocation for the rest of the elements&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Array indexing and pointer arithmetic&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#define MAXSIZE 1024&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int A[MAXSIZE], *p;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/*&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*space allocated for A&lt;br /&gt;&lt;/p&gt;&lt;p&gt;* but p – has not been given a value , even if it did here wouldn't necessarily be any space allocated *where it pointed&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Equivalent Statements&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;P = A;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P = A+I;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P = &amp;amp;A[0];&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P=&amp;amp;A[i];&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;P[0]&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;is the same as saying *p&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;p[3]&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;is the same as saying *(p+3)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Summing the Array&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;4 forms&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;1&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;sum =0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int i;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for (i=0; i&amp;lt;maxSize; i++)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sum += A[i];&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;2&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;sum = 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for(p=A; p&amp;lt;&amp;amp;A[MAXSIZE];p++)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sum+= *p;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;3&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;sum = 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For(i=0;i&amp;lt;MAXSIZE;i++&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sum += *(A+i);&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;4&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Sum = 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;P=A;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For(i=0 i&amp;lt;MAXSIZE;i++)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Sum += p[i]; /*no dereferencing*/&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Practice adding pointers and casting them&lt;br /&gt;&lt;/li&gt;&lt;li&gt;When you minus the two you get how many blocks of allocated memory exist between them&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If you cast them and minus them you get the mem address casted to ints  then you get the difference between that&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Arrays as function parameters&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;In a function header&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An array isn't declared w/ a fixed size in a function header&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Int A[] is equivalent to int *A&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;This ONLY applies to a function parameter&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Otherwise Int A[] is is NOT equivalent to int *A&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Int *A; creates a pointer variable&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Int A[] creates a constant pointer and no storage&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Pointers and strings&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Strings are arrays of char and are ended with \0&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;\0 is a null character&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;"ABC"&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Type is char*&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Value is address of the 'A'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Char word[] = "xyz"&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Is the same as char word[] = {'x','y','z','\0'};&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Char *p = "xyz";&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Word is an array of length 4.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P is a pointer and points (for now) to an array with 4 elements&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P can change reference&lt;br /&gt;&lt;/li&gt;&lt;li&gt;*p doesn't allocate new space&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Dynamic Memory Allocation&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Memory allocated while the program is running&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Stack&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;When there is a function call there are parameters and local variables&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Space set aside to hold the values for returns when functions are called&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Stacks grow during recursion&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Goes from the top down&lt;br /&gt;&lt;/li&gt;&lt;li&gt;LIFO&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;A stack grows and shrinks automatically&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Heap&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Declares space and the space remains allocated &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Malloc&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Void *malloc ( size_T n) /* memory allocation*/&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Returns pointer to n bytes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Parameter is an integer type &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Signed or unsigned&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Sets aside an amount of space&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Set aside contiguously , like an array&lt;br /&gt;&lt;/li&gt;&lt;li&gt;What is returned is a pointer to the space allocated&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If space cannot be allocated a null pointer is returned&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The storage is uninitialized&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Not necessarily emptied space&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Returns NULL if it can't be done&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Void *calloc (size_t n, size_t element_size)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Allocate enough space for this many elements that take 'so much space'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8575499339279246772?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8575499339279246772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8575499339279246772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8575499339279246772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8575499339279246772'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2031-lecture-6.html' title='CSE 2031 Lecture 6'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-981164663442595580</id><published>2008-01-24T14:15:00.001-05:00</published><updated>2008-01-24T14:15:32.576-05:00</updated><title type='text'></title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Algorithm assessment&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Is the algorithm running in constant time?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Runs the same amount of time no matter when 'n' is&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;O(1)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;No loops or constant time loops&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Linear time&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Does the problem run exactly proportional to the size of 'n'?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Dominant single loop dependant linearly on n&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Logarithmic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;The algorithm divides the size of the problem by a constant&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Runs in O(log n)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Dominant single lop is a divide by 2 on each iteration&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Assertions&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Boolean expressions or predicates that evaluate to true or false&lt;br /&gt;&lt;/li&gt;&lt;li&gt;In a program they express constraints on the state that must be true at that point&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Associate with&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Individual program statements&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Functions&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Classes&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Specify clearly, precisely and succinctly&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What is expected and guaranteed by each component&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Class function and statement&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The essence of documentation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Essential for debugging&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Aids in fault tolerance&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Result&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Result of a query but only in ensure assertions&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Current&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;@ Current object&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Void&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Not attached&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Name &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Value of the variable name before a routine starts&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Name'&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Value of the name after a routine terminates&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Alternate name 'old name' instead of Name'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;**study textual notation**&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;From online notes, cannot type all this&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;				&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-981164663442595580?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/981164663442595580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=981164663442595580' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/981164663442595580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/981164663442595580'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/algorithm-assessment-is-algorithm.html' title=''/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3212592511592582111</id><published>2008-01-22T18:38:00.001-05:00</published><updated>2008-01-22T18:38:32.303-05:00</updated><title type='text'>CSE 2031 Lecture 5</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;void makeDouble(int* x)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    *x = 2* *x;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;* modifies a pointer&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This in English is makeDouble takes an integers pointer&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Then the integers pointer is modified.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;An '&amp;amp;' sign is a pointer. int I, *p; /* means that there is an integer I and an integer memory reference *p;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;An expression has a type and value.  &lt;/strong&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;*(r=&amp;amp;j) *= *p&lt;br /&gt;&lt;/p&gt;&lt;p&gt;**p dereferences p&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Pointer to void&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Why do pointers have types? &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;So we can dereference them&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;				&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3212592511592582111?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3212592511592582111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3212592511592582111' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3212592511592582111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3212592511592582111'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2031-lecture-5.html' title='CSE 2031 Lecture 5'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4007267147270833658</id><published>2008-01-22T12:34:00.001-05:00</published><updated>2008-01-22T12:34:03.779-05:00</updated><title type='text'>Eats 1011 Lecture 6</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;ITCZ -  intertropical Convergence Zone&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ERBE – Earth Radiation Budget Experiment&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Designed to study the radiative energy&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Measures radiation coming from the atmosphere&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Tropics&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Solar heating is greater than IR cooling&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Polar Regions &lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Solar heating is less than IR cooling&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Heat transfers between the two to stop the earth from getting really hot in some areas and really cold in others&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Water Vapour in the Atmosphere&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Mixing ratio&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Troposphere is between 10&lt;sup&gt;-2&lt;/sup&gt; to 10&lt;sup&gt;-5&lt;/sup&gt; by volume or mass with most in the lower troposphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Global average ~2.5*10&lt;sup&gt;-3&lt;/sup&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;Stratosphere 4*10&lt;sup&gt;-6&lt;/sup&gt; by volume&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Latent Heat&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Energy is required/released for a phase change&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Heat storage when liquid converts to vapour&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Heat release when vapour turns to water&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;L&lt;sub&gt;v&lt;/sub&gt; – vaporization – 2.5 * 10&lt;sup&gt;6&lt;/sup&gt; J/Kg&lt;br /&gt;&lt;/li&gt;&lt;li&gt;L&lt;sub&gt;f&lt;/sub&gt; – fusion / freezing – 3.3*10&lt;sup&gt;5&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;div&gt;L&lt;sub&gt;s&lt;/sub&gt; – sublimation – L&lt;sub&gt;u  + &lt;/sub&gt;L&lt;sub&gt;f&lt;/sub&gt; – 2.8*10&lt;sup&gt;6&lt;/sup&gt;&lt;br /&gt;									&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Energy required / released when 1Kg of material changes state&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;To calculate the amount of energy required for evaporation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Need mass of water&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;2cm = 0.02m rain (over each m&lt;sup&gt;2&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Density water, p&lt;sub&gt;w&lt;/sub&gt; = 1000kg/m&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;Mass = 20kg/m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mean water mixing ratio ~ &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Mass water = &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Removal rate is estimated from the globally average rainfall ~ 1m / year&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This is equivalent to about &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mass over 1m&lt;sup&gt;2&lt;/sup&gt; ~ /m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;= 1000 kg/m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;Turnover time &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;t&lt;sub&gt;residence&lt;/sub&gt; = (25kg/m&lt;sup&gt;2&lt;/sup&gt;) / (1000 kg/m&lt;sup&gt;2&lt;/sup&gt; *  year)&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4007267147270833658?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4007267147270833658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4007267147270833658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4007267147270833658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4007267147270833658'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats-1011-lecture-6.html' title='Eats 1011 Lecture 6'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5976831319443236685</id><published>2008-01-20T19:37:00.001-05:00</published><updated>2008-01-20T19:37:34.998-05:00</updated><title type='text'></title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;Delete me&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5976831319443236685?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5976831319443236685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5976831319443236685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5976831319443236685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5976831319443236685'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/delete-me.html' title=''/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5328080202012228175</id><published>2008-01-17T18:18:00.001-05:00</published><updated>2008-01-17T18:18:19.523-05:00</updated><title type='text'>CSE 2031 Lecture 4</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Strings&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;strlen(s)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;returns length&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;strcmp(s,t)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;returns positive if s&amp;gt;t, negative if s&amp;lt;t, and 0 if they are equal.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;strcat(s,t)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;concatenates t onto s&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;changes string s&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;looks or \o and contatenates at that spot&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;Int main(void)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;char s1[] = {'H','e','l','l','o','\o'};&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;char s2[4];&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("Address of s1 is %p\n", s1);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("address of s2 is %p\n", s2);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("Enter a line: ");&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;&lt;strong&gt;f&lt;/strong&gt;gets(s2, &lt;strong&gt;sizeof(s2), stdin&lt;/strong&gt;);/* &lt;strong&gt;bolded represent extras for using f&lt;/strong&gt;gets*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("%s\n", s2);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("%s\n", s1);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;Fgets is the new one that works better, if you use just gets you will run into problems with memory over runs&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;Where s1 in this example can be overwritten by s2 if the user input is long enough&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;&lt;em&gt;Look up input and output in textbook&lt;br /&gt;&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;With fgets it will only take in the amount of characters assigned after the first comma&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;However if less than the specified amount is passed and the enter key is pushed, the new line character will count as 1 char&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='font-family:Arial; text-decoration:underline'&gt;Pointers&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int n = 5;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int *p;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;p = &amp;amp;n&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("%d\n", *p);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("%d\n", n);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;span style='font-family:Arial'&gt;*p = 7; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span style='font-family:Arial'&gt;Changes whatever value P was addressing to 7&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;If n = 5, and you said this before printing, it would print 7&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5328080202012228175?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5328080202012228175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5328080202012228175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5328080202012228175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5328080202012228175'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2031-lecture-4.html' title='CSE 2031 Lecture 4'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7188261637104947213</id><published>2008-01-17T18:11:00.001-05:00</published><updated>2008-01-17T18:11:25.860-05:00</updated><title type='text'>EATS 1011 Lecture 5</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Co&lt;sub&gt;2&lt;/sub&gt; has less of an impact on global warming than waper vapour, but CO&lt;sub&gt;2&lt;/sub&gt; can be controlled, water vapour isn't something humans can control&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The surface temperature would be exactly the same as the effective temperature if we had no  atmosphere but 30% albedo&lt;br /&gt;&lt;/li&gt;&lt;li&gt;T&lt;sub&gt;effective&lt;/sub&gt; =&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Greenhouse effect&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Dilute solar radiation heats (mostly) surface&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Surface heats and emits mid-IR radiation which is absorbed(mostly) by atmospheric gases and clouds&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The gases such as water vapour(clouds), carbon dioxide are what cause the greenhouse effect because they absorb radiation from the sun&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Atmosphere re-radiates&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Up to space&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Back down to earth&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Surface is heated "twice" (solar + mid-IR)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Figure 212 on slide&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Red skys are caused by Rayleigh scattering &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;br /&gt; &lt;/div&gt;&lt;ul&gt;&lt;li&gt;Where lambda is the wavelength&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Albedo&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Refers to visible part of the light spectrum&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Albedo depends on the surface  the light is directed to&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Fresh snow is most reflective, 75-95% light reflected&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Earth is about 30% 'albedo' &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Not sure how to use the word 'albedo'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;6% reflected from atmosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;20% reflected by clouds&lt;br /&gt;&lt;/li&gt;&lt;li&gt;4% is reflected naturally by the earth's surface&lt;br /&gt;&lt;/li&gt;&lt;li&gt;51% of solar energy heats the Earth's surface&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Total energy budget&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;										&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Most infrared is absorbed by the earth's atmosphere instead of being released into space&lt;br /&gt;&lt;/li&gt;&lt;li&gt;When the sun goes down at night we don't freeze because infra red energy from the atmosphere continues heating the earth while the sun is down&lt;br /&gt;&lt;/li&gt;&lt;li&gt;70 units of solar coming in , 50 heating the surface, after all the processing we have 70 units of energy leaving in the mid infrared&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Earth's Energy Budget&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Top of atmosphere&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;70 units of solar in balanced by 70 units of Mid-IR emitted&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Surface&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Heated twice&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Solar 51 units and 96 mid-IR units&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;We are heated by mid-IR at night&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Read slides for more details on the web&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Seasons&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What are the drivers of the seasons&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the tropics there are no seasons&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Seasons are at mid latitudes&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;orbital parameters&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;ellipticity of orbits&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Perihelion&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;147 x 10&lt;sup&gt;6&lt;/sup&gt; km, 4&lt;sup&gt;th&lt;/sup&gt; january&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Ephelion&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;153 x 10&lt;sup&gt;6&lt;/sup&gt; km, 4&lt;sup&gt;th&lt;/sup&gt; July&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;7% change in insolation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Insolation: &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The suns energy averaged over 24 hours&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Obliquity: tilt&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Rotation axis – pole star&lt;br /&gt;&lt;/li&gt;&lt;li&gt;23.5 degrees&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Solstice&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;N pole sun 21&lt;sup&gt;st&lt;/sup&gt; June, sun overhead at noon at tropic of Cancer(23.5N)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;S pole sun 21&lt;sup&gt;st&lt;/sup&gt; December, sun overhead at noon at the tropic of Capricorn (23.5S)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Regions of perpetual day and night&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Equinox&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Axis 90 to sun – earth line&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Vernal 21&lt;sup&gt;st&lt;/sup&gt; march&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Autumnal 21&lt;sup&gt;st&lt;/sup&gt; September&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Effects the length of the day&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;So what causes the seasons&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Ellipticity&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;7% so little impact&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Except over eons&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Obliquity&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Large effect at mid- and polar latitudes&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Latitude&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the tropics changes driven by overhead sun&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Wet and dry seasons&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Twice a year&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Length of day light for various latitudes&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7188261637104947213?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7188261637104947213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7188261637104947213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7188261637104947213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7188261637104947213'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats-1011-lecture-5.html' title='EATS 1011 Lecture 5'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3567987981373003122</id><published>2008-01-17T18:10:00.001-05:00</published><updated>2008-01-17T18:10:52.374-05:00</updated><title type='text'>CSE 2011 Lecture 5</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Testing and Debugging&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Create a test plan application that will probe the program with input and compare its output to see if the program is outputting the desired output from the test&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Verification&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Does the software meet its specifications&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Validation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Does the software meet its requirements&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Identify test criteria&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What are the goats for comparing the system against its spec&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Reliability, completeness, robustness&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Identify target components for testing&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In an OO system the classes and class hierarchies&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Generate test cases&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Produce test cases that can identify faults in an implementation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Execute test cases against target components&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Evaluation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If expected outputs are not produced, a bug report is issued&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Black box testing&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Testing based on input and output alone&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Do not consider underlying implementation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Test cases are generated from the spec&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Pre and post conditions&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Specific kinds of black box testing&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Random testing&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Generate random inputs&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Easy to generate cases&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Good at detecting failures&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Must be able to easily generate expected output&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Partition testing&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Cannot try all possibly inputs&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Partition input into equivalence classes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Every value in a class should behave similarly&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Test cases&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Just before the boundary&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Just after the boundary&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On a boundary&lt;br /&gt;&lt;/li&gt;&lt;li&gt;One from the middle of an equivalence class&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Loops&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Zero times through the body&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Once through the body many times through the body&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3567987981373003122?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3567987981373003122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3567987981373003122' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3567987981373003122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3567987981373003122'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2011-lecture-5.html' title='CSE 2011 Lecture 5'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2707801758950101432</id><published>2008-01-15T18:43:00.001-05:00</published><updated>2008-01-15T18:43:31.157-05:00</updated><title type='text'>CSE 2031 Lecture 3</title><content type='html'>&lt;span xmlns=''&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Integer types:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;char&lt;br /&gt;&lt;/li&gt;&lt;li&gt;short&lt;br /&gt;&lt;/li&gt;&lt;li&gt;int&lt;br /&gt;&lt;/li&gt;&lt;li&gt;long&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Floating point types:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;float&lt;br /&gt;&lt;/li&gt;&lt;li&gt;double&lt;br /&gt;&lt;/li&gt;&lt;li&gt;long double&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Char&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;1 byte long&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;char&amp;lt;= short&amp;lt;=int&amp;lt;=long&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;denote characters in single quotes &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;\0  is a null character&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;char *b = "TEST";&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;is a string writer (assumption)&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;EOF&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Reads as -1&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;								&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Which is an array of ones&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;getchar() reads a byte of unsigned chars and stores 4 bytes to represent them &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;the promotion to int is done as a signed char&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;This is because of things like EOF&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A signed char&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Fills the other bytes with the first bit of the signed char&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If it is signed and starts with 0&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;								&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;It is non negative&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If it starts with 1 &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;								&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;It is a negative number&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;An unsigned &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Does not fill the other 3 bytes with the first bit but with all 0's when promoted to an int&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Declarations&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;when you declare a variable in C it is visible throughout the score of the brackets that it is withheld&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;if you want a variable to be visible throughout a program put it above the main&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;to make one variable local to a file use the word 'static'&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;String&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;an array of char&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;there is no 'String' in C&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Arrays&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;to declare an array in C &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;use type name[size]&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;								&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;example: int number[10]&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;you can initialize an array w/o a specified size&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;char s[] = {'h','e','l','l','o','\0', 'q'}&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;printf("%s /n", s}&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;								&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;returns 'hello'&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;										&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;note there is no q, that is because null character was before it&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;											&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;printF&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;%d prints integers&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;%s prints char characters&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Prints until it finds a null character&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Null character is \0&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;%p prints the address&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;					&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Console&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Od –cb filename&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Describes a file in bits&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2707801758950101432?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2707801758950101432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2707801758950101432' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2707801758950101432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2707801758950101432'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2031-lecture-3.html' title='CSE 2031 Lecture 3'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7705672789547017867</id><published>2008-01-15T14:11:00.001-05:00</published><updated>2008-01-15T14:11:08.343-05:00</updated><title type='text'>CSE 2011 Lecture 4</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Inheritance&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;An object is a collection of data and methods to operate on that data&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Method is a procedure, function, operation&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;For a motor&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;turnOn &lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;turnOff&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;setSpeed&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;An Object is an instance of a Class&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The class provides the template for the object&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Template gives&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Data&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Methods&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Class contains methods, objects contain the data&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;						&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Typically pictured as an object pointing to the class&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Because the object uses methods&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Objects share methods&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;							&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Container&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;A collection of data is stored in a container &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The data can be of different sub-types&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Containers can be organized in different ways&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Sequence,&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Tree's&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Table&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Sequence&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;A list of objects in order&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Contains a head, front,  tail and last&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Sequence = &amp;lt;head. ^ tail = front ^ &amp;lt;last&amp;gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7705672789547017867?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7705672789547017867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7705672789547017867' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7705672789547017867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7705672789547017867'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2011-lecture-4.html' title='CSE 2011 Lecture 4'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4262214442882402311</id><published>2008-01-15T12:32:00.001-05:00</published><updated>2008-01-15T12:43:58.725-05:00</updated><title type='text'>EATS 1011 Lecture 4</title><content type='html'>&lt;span xmlns=""&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;In the northern hemisphere high pressure system goes clockwise, low pressure systems go counter-clockwise&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;This is due to the 'Coriolis effect'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;GEOS bright colours represent 'cold'&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;E&lt;sub&gt;&lt;span style="font-family:Symbol;"&gt;Å&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;is the solar energy at 1 AU ("constant")&lt;br /&gt;&lt;/li&gt;&lt;li&gt;1 AU = 1.5.10&lt;sup&gt;8&lt;/sup&gt; km = 1.5.10&lt;sup&gt;11&lt;/sup&gt; m&lt;br /&gt;&lt;/li&gt;&lt;li&gt;E&lt;sub&gt;&lt;span style="font-family:Symbol;"&gt;Å&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;= L&lt;span style="font-family:MS Mincho;"&gt;&lt;sub&gt;ʘ&lt;/sub&gt;&lt;/span&gt;/( 4.&lt;span style="font-family:Symbol;"&gt;p&lt;/span&gt;R&lt;sub&gt;p&lt;/sub&gt;&lt;sup&gt;2&lt;/sup&gt;) = L&lt;span style="font-family:MS Mincho;"&gt;&lt;sub&gt;ʘ&lt;/sub&gt;&lt;/span&gt;/( 4.&lt;span style="font-family:Symbol;"&gt;p&lt;/span&gt;1 AU)&lt;sup&gt;2&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;           =  1.38.10&lt;sup&gt;3&lt;/sup&gt; W m&lt;sup&gt;-2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt;L&lt;sub&gt;&lt;span style="font-family:MS Mincho;"&gt;ʘ&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;= E&lt;sub&gt;&lt;span style="font-family:Symbol;"&gt;Å&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;4.&lt;span style="font-family:Symbol;"&gt;p&lt;/span&gt;(1 AU)&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt; E(Rp) = L&lt;span style="font-family:MS Mincho;"&gt;&lt;sub&gt;ʘ&lt;/sub&gt;&lt;/span&gt;/( 4.&lt;span style="font-family:Symbol;"&gt;p&lt;/span&gt;Rp&lt;sup&gt;2&lt;/sup&gt;) = E&lt;sub&gt;&lt;span style="font-family:Symbol;"&gt;Å&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;/(Rp/1 AU)&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt;&lt;sup&gt;        &lt;/sup&gt;      = E&lt;sub&gt;&lt;span style="font-family:Symbol;"&gt;Å&lt;/span&gt;&lt;br /&gt;   &lt;/sub&gt;/Rp&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt;Rp  measured in AU&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;37% of energy from the solar spectrum is near infrared&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Most energy from the sun is less than 1 micron&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;We can see light where the sun outputs the most energy&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The sun emits mostly in the UC, visible and near infrared regions&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Humans can only see the visible region&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The earth emits almost all in the mid infra red region&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Satellites measuring IR can pick up differences in temperatures (clouds, water, surface, etc)&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The area under the solar-radiation curve is the total (all wavelengths) solar radiance reaching the earth's orbit&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;=1.38*10&lt;sup&gt;3&lt;/sup&gt; W m&lt;sup&gt;-2&lt;/sup&gt;&lt;br /&gt;    &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;Planetary Effective temperatures&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The sun is far enough away to consider its rays parallel to eachother&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Some light scatters back into space&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The difference between infra red and solar energy is solar energy only comes through during the day&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Emitted light as opposed to scattered&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Albedo&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;em&gt;A&lt;/em&gt; =&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Radius of planet, b&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Atmosphere emits as Planck body, &lt;span style="font-family:Symbol;"&gt;s&lt;/span&gt;T&lt;sup&gt;4 &lt;/sup&gt;W/m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt;&lt;div&gt;Steady state energy balance&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Heating = cooling&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Absorption (area*flux) = emission(area*flux)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;    &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Total amount of energy intercepted = π b&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;  &lt;/li&gt;&lt;li&gt;T&lt;sub&gt;eff&lt;/sub&gt; = effective temperature&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Earth, rp 1AU&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Albedo = .3 ( i.e. 70% of energy absorbed)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;T&lt;sub&gt;eff&lt;/sub&gt; = 255 Kelvin, = -18 Celcius&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;But The mean temperature is about 15 Celcius&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;T = 33 celcius&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;What is the implication for this temperature difference?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Natural greenhouse effect&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Main greenhouse gas in the atmosphere is water vapour&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Earth radiates / cools in the mid – IR (Wien's Law) from about 5km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Obliquity&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;the tilt of the planet from the sun&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;    &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Mercury – rotates slowly and has a very large d/n temperature difference because heat deposited locally cannot be rapidly transferred to other locations such as the night side&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Venus – T of 700k is actually the surface temperature and is evidence of a large greenhouse effect&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Earth   - natural greenhouse effect of about 33C&lt;/li&gt;&lt;li&gt;Mars    - small greenhouse effect&lt;/li&gt;&lt;li&gt;Jupiter  - interior heating - gravitational contraction&lt;/li&gt;&lt;li&gt;saturn - same&lt;/li&gt;&lt;li&gt;uranus - no&lt;/li&gt;&lt;li&gt;neptune - same as J and S&lt;/li&gt;&lt;li&gt;Pluto - aerosols and methane lead to a greenhouse effect&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;Heating of the Earth by Radiation&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Solar radiation incident on atmosphere&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Dilute 6000 K radiation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Scatters off air, clouds (numbers later)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Absorbed by aerosols, clouds, gases&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Overall visible fairly transparent&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Surface absorbs most radiation &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Albedo trees(15%, ocean 10%)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Mid-IR radiation emitted from Earth / atmosphere system&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Also called terrestrial radiation / long wavelength&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mid-IR is quite absorptive&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"windows" 8-9, 10-12 чm&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Main absorbers&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;H&lt;sub&gt;2&lt;/sub&gt;O, CO&lt;sub&gt;2&lt;/sub&gt;, clouds&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Seconday absorbers&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;CH&lt;sub&gt;4&lt;/sub&gt;, N&lt;sub&gt;2&lt;/sub&gt;O, CFCI&lt;sub&gt;3&lt;/sub&gt;,CF&lt;sub&gt;2&lt;/sub&gt;Cl&lt;sub&gt;2, &lt;/sub&gt;O&lt;sub&gt;3&lt;/sub&gt;&lt;br /&gt;      &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Absorption of radiation &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;For graph on absorption&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;100 = total absorption&lt;br /&gt;&lt;/li&gt;&lt;li&gt;0 = no absorption&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;O&lt;sub&gt;2&lt;/sub&gt; and O&lt;sub&gt;3&lt;/sub&gt; absorb very energetic radiation from the sun&lt;br /&gt;&lt;/li&gt;&lt;li&gt;At about 9.6 microns ozone is acting as a greenhouse gas&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Nitrous oxide&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;No role in visible spectrum&lt;br /&gt;&lt;/li&gt;&lt;li&gt;At about 4 microns and 6 microns absorbs quite a lot of energy&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Methane&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Heats the atmosphere a little bit&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Plays a major role at about 6 microns&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Water vapour&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Water vapour absorbs a long range&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Short mid and long range&lt;br /&gt;&lt;/li&gt;&lt;li&gt;From 4 -8 microns it plays a major rold&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Plays a major role in controlling earths temperature&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Carbon dioxide&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Heats the atmosphere because it absorbs infrared radiation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Major band at about 15 microns&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Most visible radiation goes to the surface&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;Transmission of solar and IR radiation&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4262214442882402311?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4262214442882402311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4262214442882402311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4262214442882402311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4262214442882402311'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/in-northern-hemisphere-high-pressure.html' title='EATS 1011 Lecture 4'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-1555376335483806758</id><published>2008-01-10T18:47:00.001-05:00</published><updated>2008-01-10T18:47:21.347-05:00</updated><title type='text'>CSE 2031 Lecture 2</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Course Information&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;15% on assignments&lt;br /&gt;&lt;/p&gt;&lt;p&gt;30 % on midterm&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Rest on exam&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Recap from day 1&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;-Wall&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Shows any errors the compiler wouldn't typically catch&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;-o&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Allows you to change the executable files filename&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;-c&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; Stops compilation after the object module is produced&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;-E&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; Stops the compilation after the preprocessor phase&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Textual manipulation of the source code&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int main(void)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    int n, m;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    int product = 1; /* will eventually hold n!*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    scanf("%d, &amp;amp;n);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    m=n;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    while ( m &amp;gt; 0)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;        product *= m--;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    printf("%d! = %d\n", n, product);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int factorial(int)    /* must be declared here in case user inputs a non-int*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int main(void)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int n;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;scanf("%d", &amp;amp;n)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("%d! = %d\n", n, factorial(n));&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int factorial(int x)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    /* base case*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;if (x&amp;lt;2) return 1;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;    /*recursive calls*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;return x*factorial(x-1);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;/*returns 5! = 120*/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you want to compile with two files linking eachother use &lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;cc -0 printFactorial factorial.c printfactorial2.c&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;this will link the code used in printFactorial from factorial.c so that printFactorial will work&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;this is more explicit than java because there isn't an 'import' feature&lt;br /&gt;&lt;/li&gt;&lt;li&gt;instead the feature is found in the compiler&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;when you compile a program that uses multiple files you have to name all the files on the command line&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;utility 'make'&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;merges files together&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;looks for a 'makefile' &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;in a make file there are dependency lines or action lines&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;action lines MUST be tabbed over&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;dependency lines describe the files in use&lt;br /&gt;&lt;/li&gt;&lt;li&gt;action lines tell console what to do to generate the file described in the dependency file&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;when 'make' is typed in console it runs the commands found in makefile&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;read makefile on course website, when it is available&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;console: make clean &lt;br /&gt;&lt;/li&gt;&lt;li&gt;runs the clean command found in 'makefile'&lt;br /&gt;&lt;/li&gt;&lt;li&gt;all warning flags are put in 'makefile' such as –Wall&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Compiler&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;–l  makes the console look in the library for functions used that aren't in stdio.h&lt;br /&gt;&lt;/li&gt;&lt;li&gt;–lm looks in the m (math) library&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main(void)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;{&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    double x;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    &lt;br /&gt;&lt;/p&gt;&lt;p&gt;    printf("Enter value for x: ");&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    scanf("%1f", &amp;amp;x);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    &lt;br /&gt;&lt;/p&gt;&lt;p&gt;    printf("x = %f sqrt(x) = %1f\n",  x, sqrt(x));&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    return 0;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-1555376335483806758?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/1555376335483806758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=1555376335483806758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1555376335483806758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1555376335483806758'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2031-lecture-2.html' title='CSE 2031 Lecture 2'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-9003143655598636462</id><published>2008-01-10T14:05:00.001-05:00</published><updated>2008-01-10T14:05:13.924-05:00</updated><title type='text'></title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Array as an Abstract Data Type&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What is an array?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An indexed, homogeneous collection of variables&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Indexed from n-1 where n is the size&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Multi dimensional&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1 index per dimension&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The upper bound must be greater than or equal to the lower bound &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;An integer&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;is four bytes long, in sequence&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;to put one thing in to memory is called 'mapping'&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;row order&lt;/strong&gt; is where the rows are separated and the columns are adjacent&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;column order&lt;/strong&gt; is the opposite&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;if you have an array going from [-5 ..+6, +1 … 10, 3…5] of chess pieces&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;you would have an array of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;-5, …, +6 of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;An array of 1 , … , 10 of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An array of 3, …, 5 of chess pieces&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Index – lower bound , to find the memory location of  an object in a one dimensional array&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For multi dimensional the 2&lt;sup&gt;nd&lt;/sup&gt; 3&lt;sup&gt;rd&lt;/sup&gt;… n dimensions start at the end point of the first but find an index the same way as a 1 dimensional array&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Array Descriptor&lt;/span&gt;&lt;br /&gt;					&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Dimension count&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For each dimension it needs to lower bound and upper bound and total size&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A prototype array descriptor&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;    &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;A&lt;sub&gt;0&lt;/sub&gt; is the hypothetical location in memory where the first lower bound is found in memory.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-9003143655598636462?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/9003143655598636462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=9003143655598636462' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/9003143655598636462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/9003143655598636462'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/array-as-abstract-data-type-what-is.html' title=''/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-695326772879774601</id><published>2008-01-10T14:03:00.001-05:00</published><updated>2008-01-10T14:03:57.300-05:00</updated><title type='text'>CSE 2011 Lecture 3</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Array as an Abstract Data Type&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;What is an array?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An indexed, homogeneous collection of variables&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Indexed from n-1 where n is the size&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Multi dimensional&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1 index per dimension&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The upper bound must be greater than or equal to the lower bound &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;An integer&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;is four bytes long, in sequence&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;to put one thing in to memory is called 'mapping'&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;row order&lt;/strong&gt; is where the rows are separated and the columns are adjacent&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;column order&lt;/strong&gt; is the opposite&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;if you have an array going from [-5 ..+6, +1 … 10, 3…5] of chess pieces&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;you would have an array of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;-5, …, +6 of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;An array of 1 , … , 10 of&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;An array of 3, …, 5 of chess pieces&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Index – lower bound , to find the memory location of  an object in a one dimensional array&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For multi dimensional the 2&lt;sup&gt;nd&lt;/sup&gt; 3&lt;sup&gt;rd&lt;/sup&gt;… n dimensions start at the end point of the first but find an index the same way as a 1 dimensional array&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Array Descriptor&lt;/span&gt;&lt;br /&gt;					&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Dimension count&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For each dimension it needs to lower bound and upper bound and total size&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A prototype array descriptor&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;    &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;A&lt;sub&gt;0&lt;/sub&gt; is the hypothetical location in memory where the first lower bound is found in memory.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;				&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-695326772879774601?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/695326772879774601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=695326772879774601' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/695326772879774601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/695326772879774601'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2011-lecture-3.html' title='CSE 2011 Lecture 3'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-80743015880763626</id><published>2008-01-10T11:51:00.001-05:00</published><updated>2008-01-10T11:51:56.331-05:00</updated><title type='text'>EATS 1011 Lecture 3</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Energy&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Ability or capacity to do work&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Comes in many forms, kinetic, potential, heat, etc&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Energy is conserved &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1&lt;sup&gt;st&lt;/sup&gt; law of thermodynamics&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Work is done on matter if it is pushed, pulled or lifted over some distance&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example: lifting implies exerting force against gravity&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;By doing work on something we give it energy which can be used to do work on something else&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example pulling a spring gives stored potential energy&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The energy stored in an object (internal energy) determines how much work it can do. This is called gravitational potential energy or potential energy &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; potential to do work &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example potential energy lifting a mass through a height&lt;br /&gt;&lt;/li&gt;&lt;li&gt;–PE = mgh&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Where&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;M = mass(kg)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;G = gravitational acceleration(m/S&lt;sup&gt;2&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;H = distance lifted (m)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Unites of energy&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;1 erg = 1 dyne/cm = 2.388 x 10&lt;sup&gt;-8&lt;/sup&gt;cal&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;1 joule (j) = 1 newton meter (N.m) = .239cal&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;=10&lt;sup&gt;7&lt;/sup&gt;&lt;sub&gt;&lt;br /&gt;							&lt;/sub&gt;erg&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;1 calorie (cal) = 4.186 J = 4.186 * 10&lt;sup&gt;7&lt;/sup&gt; erg&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Chemical potential energy&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A substance has potential energy if it can do work when a chemical change can occur (coal , natural gas, chemicals, food have PE)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Kinetic energy (KE) = energy of motion&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;KE = ½ mv&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Where:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;M = mass(kg)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;V = velocity (m/s)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Faster moving &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; higher KE&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example strong wind has more KE&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Kinetic energy of random motion is often referred o as Heat Energy&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Energy can't be destroyed or created, it only moves from one form to another&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Atmospheric Heating&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Conduction&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Molecular motions&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Near surface&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Thermosphere&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Convection&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Macroscopic motions&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example winds, turbulence&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Horizontal, vertical&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Hot air rises&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example a hot surface transferring hot surface energy into the atmosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Latent heat&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Condensation to evaporation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Freezing/fusion/melting&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Sublimation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;As water goes through the three phases energy about 1 million joules per kilogram of ice to have it turn to water&lt;br /&gt;&lt;/li&gt;&lt;li&gt;And 2.5 million joules for water to turn to vapour&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Radiation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Energy transfers at the speed of light&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Electromagnetic Radiation&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;EMR/ light has both wave and particle properties(photon)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;λ  -Wavelength(m)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;v – frequency (s&lt;sup&gt;-1&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;C = λv = 3*10&lt;sup&gt;8&lt;/sup&gt;m/s&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The speed of light&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;E = hv(j)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;H = 6.636*10&lt;sup&gt;-34&lt;/sup&gt;Js&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;"black body or planck Body: is a hypothetical body that emits radiation in a manner so that the total amount of en4ergy is only a function of temperature and spectral shape is a universal function with a single peak  (see later) (P35)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The total amount of energy (integrate over v) crossing a square meter per second is given by Stefan-Boltzman Law&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;E(T) = λT&lt;sup&gt;4&lt;/sup&gt;Wm&lt;sup&gt;-2&lt;/sup&gt;&lt;br /&gt;								&lt;/li&gt;&lt;li&gt;Where λ = 5.67 * 10&lt;sup&gt;-8&lt;/sup&gt; W m&lt;sup&gt;-2&lt;/sup&gt;K&lt;sup&gt;-4&lt;/sup&gt; is the Stefan-Boltzman constant&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The location of the peak is given by &lt;strong&gt;Wien's Law&lt;/strong&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;&lt;div&gt;Question: what is the wavelength of the maximum radiation emitted by the earth and by the sun?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;for Eatrch the average surface temp is &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;288Kelvin(15C)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;For the sun&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;6000 kelvin&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Using wien's law we can find the wavelength of the maximum radiation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;For earth λ&lt;sub&gt;max&lt;/sub&gt; ~ 10um mid-IR radiation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;For te sun λ&lt;sub&gt;max&lt;/sub&gt; ~ .5um visible radiation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Solar Properties&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Main sequence star&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Burns H – fusion&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Layers&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Core ~ 10&lt;sup&gt;7&lt;/sup&gt;k&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Radiative zone&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Convective zone&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Photosphere ~ 6000k (&lt;strong&gt;What we see)&lt;/strong&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;Chromospheres ~ 4000k&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Corona ~ 1 000 000k&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Sun spots ("cold") prominences, granules, spicules, etc&lt;br /&gt;&lt;/li&gt;&lt;li&gt;R&lt;sub&gt;0&lt;/sub&gt; ~ 700 000km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Emits L&lt;sub&gt;(sun)&lt;/sub&gt; = 3.9 * 10&lt;sup&gt;26&lt;/sup&gt;W&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Spectrum ~ planck body = f(v,t) universal function&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Use S-B equation give T&lt;sub&gt;sun&lt;/sub&gt; ~ 5700k (effective temperature)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Solar cycle ~ 11 years&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Total output variation &amp;lt;.1% over 20 years&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;EUV &amp;gt; 3&lt;br /&gt;&lt;/li&gt;&lt;li&gt;X-Ray ~ 100 &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;The more sunpots, the more energy from the sun&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Which is interesting because the sun gives off most heat when it has the most spots with 'cold spots'&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-80743015880763626?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/80743015880763626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=80743015880763626' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/80743015880763626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/80743015880763626'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats-1011-lecture-3.html' title='EATS 1011 Lecture 3'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7007307882297598360</id><published>2008-01-08T14:07:00.001-05:00</published><updated>2008-01-10T13:03:00.550-05:00</updated><title type='text'>CSE 2011 Lecture 2</title><content type='html'>&lt;span xmlns=""&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Abstract data types&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Definition:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Abstract:&lt;/strong&gt; to take out irrelevant information and obtain what is important&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Data:&lt;/strong&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Type:&lt;/strong&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Definition: a model of a set of objects together with a set of operations on them&lt;/strong&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;Abstract &lt;span style="font-family:Wingdings;"&gt;à&lt;/span&gt; model of subset of all possible properties&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Objects are nouns, operations are verbs&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Only a first approximation but useful at the boundary with the world&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Any collection of nouns and verbs is an ADT&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Difficulty is to define good and useful ADT's&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Objects can be divided into two categories&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The objects themselves&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;And the meta objects&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Descriptions of other objects&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Programmer is interested in them to build good models with finite resources such as memory and disk&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Sizes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Amounts&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;5 basic operations&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Enquiry&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Read&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Typically return user data&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Typically should not change the meta data&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Write&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Changes the meta data&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Writing meta data into file&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Reorganize&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Changes the physical relation ships among real objects&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Sort a list by names&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Test&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Not strictly a part of ADT&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Useful for implementers&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Documentation&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Operations&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Give&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Signature&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Informal description&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Pre and post conditions&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Use natural language, mathematics, diagrams – whatever best gets the meaning across&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Be simple complete, clear, precise, concise as possible&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Axioms&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Describes axioms about operations in a program&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Example: new account starts balance at 0      &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Invariants&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Conditions that must be true after the execution of any method in the class&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;The conditions that hold, at all times, among the objects in an instance of the ADT&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;More on this when we discuss design by contract&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7007307882297598360?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7007307882297598360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7007307882297598360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7007307882297598360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7007307882297598360'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2011-lecture-2.html' title='CSE 2011 Lecture 2'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7867346901123913322</id><published>2008-01-08T11:17:00.001-05:00</published><updated>2008-01-08T11:17:28.722-05:00</updated><title type='text'>Eats 1011 Lecture 2</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;From Last Lecture&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Photosynthesis&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;N(CO&lt;sub&gt;2&lt;/sub&gt; + sunlight &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt;(H&lt;sub&gt;2&lt;/sub&gt;CO)n + nO&lt;sub&gt;2&lt;/sub&gt;(day)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;O&lt;sub&gt;2&lt;/sub&gt; + H&lt;sub&gt;2&lt;/sub&gt;CO &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; CO&lt;sub&gt;2&lt;/sub&gt; + H&lt;sub&gt;2&lt;/sub&gt;O(night)"burning" (energy release)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Death/burial oc C &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; O&lt;sub&gt;2&lt;/sub&gt; remains in atmosphere&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Summary &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Most of the carbon is in sedimentary rocks so that the CO&lt;sub&gt;2&lt;/sub&gt; – N&lt;sub&gt;2&lt;/sub&gt; **&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Carbon budget(arb units)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Biosphere: &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Marine: 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Non-marine: 1&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Atmosphere: 70&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Ocean – dissolved : 4000&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Fossil fuels : 800&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Shales: 800 000&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Carbonate Rocks: 2 000 000&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Pressure and density&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In talking of the atmosphere in a quantitative fashion we need to be concerned about certain fundamentals&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Pressure, P, of a gas&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Force/area = Newtons/m&lt;sup&gt;2&lt;/sup&gt; = Pascal(Pa)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Two ( at least) views&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Microscopic or macroscopic&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Microscopic or kinetic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Collisions and rate of change of momentum&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Macroscopic&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The barometer, 1644&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Column of mercury balances air pressure&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Pressure&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;=weight of air / area&lt;br /&gt;&lt;/li&gt;&lt;li&gt;= mass / m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;												&lt;/li&gt;&lt;li&gt;note that as we ascend there is lenss air so that pressure decreases with altitude&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;surface pressure at MSL (mean sea level)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;101.32 kPa&lt;br /&gt;&lt;/li&gt;&lt;li&gt;=1013.2 mb (millibars)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;=760 mm Hg = .76 metres Hg&lt;br /&gt;&lt;/li&gt;&lt;li&gt;=29.2 inches Hg&lt;br /&gt;&lt;/li&gt;&lt;li&gt;=32 feet of water approx 10 meters of water&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mass of air over 1 m&lt;sup&gt;2&lt;/sup&gt; = P/g ~ 10&lt;sup&gt;5&lt;/sup&gt;/10&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;= 10&lt;sup&gt;4&lt;/sup&gt; kg = 10 tonnes / m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;																	&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;*1mb = 100 Pa = 1hPa&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Back to origins&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If oceans evaporated, what would the pressure be?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The weight of column of water – per square meter&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mass of water over 1 m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;																	&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Density * volume = &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;10&lt;sup&gt;3&lt;/sup&gt;kg/m&lt;sup&gt;3&lt;/sup&gt; x 3.2*10&lt;sup&gt;3&lt;/sup&gt; m*1m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;																				&lt;/li&gt;&lt;li&gt;=3.5 * 10&lt;sup&gt;6&lt;/sup&gt; kg/m&lt;sup&gt;2&lt;/sup&gt;&lt;br /&gt;																				&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Weight = mass *g &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;~ 3.5 * 10&lt;sup&gt;7&lt;/sup&gt; Pa = 350 atm&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Pressure of gas = force per unit area (Pa)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Boyles law, P∞ 1/v &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;T constant &lt;br /&gt;&lt;/li&gt;&lt;li&gt;V volume&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Charles Law V∞ T &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;P constant&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Combine as perfect gas law (PGL) or equation of state&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;P pRT&lt;br /&gt;&lt;/li&gt;&lt;li&gt;R = R*/M(gas constant)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;R* = 8.314*x10&lt;sup&gt;3&lt;/sup&gt; J/K/kmole (universal gas constant&lt;br /&gt;&lt;/li&gt;&lt;li&gt;M = kg molecular weight&lt;br /&gt;&lt;/li&gt;&lt;li&gt;T = temperature in degrees Kelvin = 273.16+ T(°C)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Density at MSL p = P/RT&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;M = kg molecular weight = 29 kg/kmole&lt;br /&gt;&lt;/li&gt;&lt;li&gt;R = R*/M&lt;br /&gt;&lt;/li&gt;&lt;li&gt;R*/29kg/ kmole = 287 J/K/kg&lt;br /&gt;&lt;/li&gt;&lt;li&gt;T = 27°C = 300K&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P = P/RT = 10&lt;sup&gt;5&lt;/sup&gt;/(287*300)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;~1.2 kg/m&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;						&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Vertical Structure&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Vertical variation (Z) of pressure in the atmosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;(&lt;em&gt;get diagram from website)&lt;/em&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;&lt;div&gt;Stationary cylinder&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Cross sectional area, A&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Density, p(kg/M&lt;sup&gt;3&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Weight of cylinder downwards is balanced by net upward pressure force&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mass of cylinder = volume * density&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;DZ * Axp&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Force balance (upwards)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;(P + dP) * A + P * A – dZ*A*p*g = 0&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Simplify&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;dP/dZ = -pg – &lt;strong&gt;Hydrostatic Law&lt;/strong&gt;&lt;br /&gt;								&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;H = RT/g(m) = 8km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P(0) = 1.013*10&lt;sup&gt;2&lt;/sup&gt;kPa&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P(0) = 1.2 kg/m&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;						&lt;/li&gt;&lt;li&gt;P(Z) = p(0) * exp(-z/h)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;p(Z) = p(0) * exp(-z/h)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;the higher you go upwards the less pressure in the atmosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='https://horsehead.ccs.yorku.ca/moodle/login/index.php'&gt;https://horsehead.ccs.yorku.ca/moodle/login/index.php&lt;/a&gt;&lt;br /&gt;				&lt;/li&gt;&lt;li&gt;&lt;div&gt;Mean free path(λ) (the average distance between molecules calculating a distance a molecule can travel before it collides with another&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Q*N* λ = 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Q – cross section (m&lt;sup&gt;2&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Number density, N (molec m&lt;sup&gt;-3&lt;/sup&gt;)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Surface, λ = .3 чm&lt;br /&gt;&lt;/li&gt;&lt;li&gt;300 km, λ = 100km (satellite drag)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Vertical variation of pressure – ocean&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Equation of state  p = p&lt;sub&gt;0&lt;/sub&gt;*z (z&amp;lt;0), ie P increases linearly with depth&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P doubles in z = 10 meteres, ie P(0) = p&lt;sub&gt;0&lt;/sub&gt;*g*z&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Vertical temperature Structure&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the stratosphere/ thermosphere temperature increases with height&lt;br /&gt;&lt;/li&gt;&lt;li&gt;In the troposphere/mesosphere  it decreases &lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;In order &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Troposphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Stratosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mesosphere&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Thermosphere&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Temperature structure&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Troposphere: 0-10/16km tropopause&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Stratosphere: tropopause – 50km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mesosphere: stratopause – 85km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Thermosphere: mesopause – 300km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Exosphere: above 300km  "collisionless"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Lapse rate&lt;br /&gt;&lt;/li&gt;&lt;li&gt;***&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Homosphere&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Most "inert" species are well mixed&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Heterosphere&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Species are in diffusive equilibrium i.e for each species there is a hydrostatic law&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Ionosphere&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Atmosphere is ionized by EUV&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7867346901123913322?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7867346901123913322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7867346901123913322' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7867346901123913322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7867346901123913322'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats-1011-lecture-2.html' title='Eats 1011 Lecture 2'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7859319943328508814</id><published>2008-01-03T18:45:00.001-05:00</published><updated>2008-01-03T18:45:35.058-05:00</updated><title type='text'>CSE2031 Lecture 1</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Course  Information&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Prof: Gordon Turpin&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Email: &lt;a href='mailto:gordon@cse.yorku.ca'&gt;gordon@cse.yorku.ca&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;    -only send mail from prism account&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    -use a subject header "2031: …"&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Hello World&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;int main(void)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;printf("Hello World!"\n");&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;return 0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;This file is replaced in the header in compile time&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;stdio.h does not contain executable code&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;only definition of constants &lt;br /&gt;&lt;/li&gt;&lt;li&gt;include statements&lt;br /&gt;&lt;/li&gt;&lt;li&gt;and function prototypes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;'printf' &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A function call&lt;br /&gt;&lt;/li&gt;&lt;li&gt;(method is a function, method is a java term)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;When it encounters a function call like 'printf' &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;It wants the function prototype of printf&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;int main(void)&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;'void' means it takes no parameters&lt;br /&gt;&lt;/li&gt;&lt;li&gt;'main' returns an 'int'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;return 0;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;indicates success&lt;br /&gt;&lt;/li&gt;&lt;li&gt;unspecified types are assumed to be 'int'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;printf&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;most basic print type&lt;br /&gt;&lt;/li&gt;&lt;li&gt;'\n' sends a new line after the text&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;This program doesn't return a '0' because printing is not the same as returning&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Compiling C&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Simplest way to compile&lt;br /&gt;&lt;/div&gt;&lt;p style='margin-left: 36pt'&gt;&lt;span style='font-family:Arial'&gt;cc hello.c&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style='margin-left: 36pt'&gt;&lt;span style='font-family:Arial'&gt;ls a.out&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style='margin-left: 36pt'&gt;&lt;span style='font-family:Arial'&gt;cat hello.c &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;'cat' prints out the code for hello.c  in console&lt;br /&gt;&lt;/li&gt;&lt;li&gt;cat is called from /bin/cat&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;cc is the compile command&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;cc created a.out&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;to create a different file name&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;use &lt;span style='font-family:Arial'&gt;cc &lt;span style='background-color:yellow'&gt;–o&lt;/span&gt; hello hello.c&lt;/span&gt;&lt;br /&gt;											&lt;/div&gt;&lt;ul&gt;&lt;li&gt;'hello' is the filename&lt;br /&gt;&lt;/li&gt;&lt;li&gt;-o is the 'flag' to create a different name&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;cc –o hello &lt;span style='background-color:yellow'&gt;–Wall&lt;/span&gt; hello.c&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;–Wall will allow the compiler point out errors in code&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;cc –o hello –Wall &lt;span style='background-color:yellow'&gt;-pedantic&lt;/span&gt; hello.c&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;allows you to see if code will run on older versions of C&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;cc –o hello –Wall -pedantic &lt;span style='background-color:yellow'&gt;–c&lt;/span&gt; hello.c&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; stops compilation when the object module is produced&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Produces the file 'hello.o'&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;nm hello.o&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;shows the function 'main' in the T (text)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;and there is a call for a function 'printf'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;cc –o hello –Wall –pedantic –c &lt;span style='background-color:yellow'&gt;-E&lt;/span&gt; hello.c&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; stops the compilation after the preprocessor phase&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Replaces #define with code supplied for that function&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;echo $PATH &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;returns the paths where the shell will look for the commands you are passing &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;separated by ':'&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;the last place bash looks in is the current directory&lt;br /&gt;&lt;/li&gt;&lt;li&gt;./a.out will find a.out within your path&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;PATH=$PATH:..&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Adds  ' ..'  to the $PATH&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;a.out only needs executable permission to run&lt;br /&gt;&lt;/li&gt;&lt;li&gt;if you write a shell script you would need execute and read permission&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;chmod&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;9 permission bits&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;&lt;span style='background-color:yellow'&gt;---&lt;/span&gt;------&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;User&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;---&lt;span style='background-color:yellow'&gt;---&lt;/span&gt;---&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Group&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;------&lt;span style='background-color:yellow'&gt;---&lt;/span&gt;&lt;br /&gt;							&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Owner    &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Read = 4&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Write = 2&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Execute = 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Non = 0&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;'chmod 751 a.out 'gives&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;user&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; r/w/e&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;group&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; r/e&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;owner&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;e&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Comments&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;/*&lt;span style='font-family:Arial'&gt;comment in here&lt;/span&gt; */&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;span style='font-family:Arial'&gt;&lt;br /&gt;						&lt;/span&gt; &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7859319943328508814?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7859319943328508814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7859319943328508814' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7859319943328508814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7859319943328508814'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2031-lecture-1.html' title='CSE2031 Lecture 1'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8983355029680280120</id><published>2008-01-03T17:04:00.001-05:00</published><updated>2008-01-03T17:04:31.576-05:00</updated><title type='text'>CSE2001 Lecture 1</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Course information&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Prof: George Tourlakis&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Course website: &lt;a href='http://www.cse.yorku.ca/~gt/courses/'&gt;www.cse.yorku.ca/~gt/courses/&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;Evaluation Breakdown&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Homework (30%) , Midterm (30%), Final Exam (40%)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mathematical induction is very important&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;PDA&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Push down automata&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Will accept {a&lt;sup&gt;n&lt;/sup&gt;b&lt;sup&gt;n&lt;/sup&gt;| n≥0}&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Assignments are to be typed&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;George uses LaTex for writing equations on a computer.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;mcTex is for PC&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Book authors: Hopcroft / Ullman/ Motwani&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;We will cover&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Finite Automata (FA)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Push Down Automata (PDA)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A little about TM's(mostly from Tourlakis's notes)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Feb 19&lt;sup&gt;th&lt;/sup&gt; is Test 1 &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;if a test is missed the percentage is added to the final exam &lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;other references&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;webnotes&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Sets&lt;/span&gt;&lt;br /&gt;					&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;A ,  x,  { , , ,},  { a a b}&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Used to denote sets&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Order doesn't  matter in a set&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Neither do repetitions&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;{a,a,b} == {a,b} == {b,a}&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;N - Natural numbers symbol in McTax&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;\mathb&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;{x:P(x)}&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;{X|p(x)}&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;:  and | used as 'such that' labels&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Russel paradox&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Does every math property P(x) determine a set?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;No!&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;X ε Y&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;{0} ε{1}&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;False&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;{0} ε{0}&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;True&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;How about R = {x &lt;span style='text-decoration:line-through'&gt;ε&lt;/span&gt; x}?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;x ε R == x &lt;span style='text-decoration:line-through'&gt;ε&lt;/span&gt; x&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;R &lt;span style='text-decoration:line-through'&gt;ε&lt;/span&gt; R = R &lt;span style='text-decoration:line-through'&gt;ε&lt;/span&gt; R&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8983355029680280120?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8983355029680280120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8983355029680280120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8983355029680280120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8983355029680280120'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse2001-lecture-1.html' title='CSE2001 Lecture 1'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2687579044503322311</id><published>2008-01-03T13:56:00.001-05:00</published><updated>2008-01-03T13:56:50.359-05:00</updated><title type='text'>CSE 2011 Lecture 1</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Course Information&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Website: &lt;a href='http://www.cse.yorku.ca/course/2011/'&gt;http://www.cse.yorku.ca/course/2011/&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;Workload:  3 reports(6%,7%,7%), 2 class tests(20%,20%) and a final exam(40%).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Course directly for prism: prism:/cse/course/2011&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Found here:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Java files for assignments&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Answers for assignments&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;To find your grade: &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Console:  courseInfo 2011 [2007-08 W]&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Data structures&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;A systematic way to organize and access data&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;That is easy to retrieve&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Algorithm&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Step by step procedure for performing some task in a finite amount of time&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;"Sometimes you want to use the slower algorithms because they are faster"&lt;br /&gt;&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Programs = Data Structures + Algorithms&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The course forms a framework for developing useful programs&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Principles of public design&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Principle of use&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Programs will be used by people&lt;br /&gt;&lt;/li&gt;&lt;li&gt;They are public&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Must be designed for people&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Principle of misuse&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Programs will be misused by people&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Principle of evolution&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Programs will be changed by people&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If you want to modify it you'll have to know how it works&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Principle of migration&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Programs will be moved to new environments by people&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Software quality&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Readable and understandable&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;All design artifacts – program text included – are primarily to be read and used by people&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Execution is incidental&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Correct and complete&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;It works – it is useable&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Works correctly for all possible inputs that one might encounter within a domain of interest&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;First write correct programs then worry about efficiency&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;A fast program that is wrong is worse than useless&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Speed up where necessary after instrumentation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Always design to be as efficient as you wanted to be and no more&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Efficient as it needs to be&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Use an appropriate amount of resources for the task&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Space for storing data and temporary results&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Execution time&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Space – time tradeoff&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Communications bandwidth&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Modifiable&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;All programs evolve over time&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Make plausible modifications easy&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;One sign of  a good design is it is easy to modify and adapt to changing circumstances&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;On time and on budget&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Time is money&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Pay back on investment&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Imbedded systems&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Programs are only a part of the system&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Basic data structures&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Array&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Single type of data&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Fixed size&lt;br /&gt;&lt;/li&gt;&lt;li&gt;homogeneous&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Tuple&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Collection of different types of data&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Heterogeneous&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;We want to store things in a container of the basic data structures&lt;br /&gt;&lt;/li&gt;&lt;li&gt;We want to organize data structures&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A container should be able to: &lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Add&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Remove &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Retrieve&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Find size&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;How big the container is&lt;br /&gt;&lt;/li&gt;&lt;li&gt;How many things are in the container&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If it contains something&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;organize&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A fundamental organization of a collection&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Iteration&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Move elements &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Fundamental property of a sequence&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The beginning  and the end of the sequence&lt;br /&gt;&lt;/li&gt;&lt;li&gt;There is a front a sequence and a rear to a sequence&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;A list is the organization of a container&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;				&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2687579044503322311?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2687579044503322311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2687579044503322311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2687579044503322311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2687579044503322311'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/cse-2011-lecture-1.html' title='CSE 2011 Lecture 1'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4483120384004249880</id><published>2008-01-03T11:35:00.001-05:00</published><updated>2008-01-03T11:35:20.970-05:00</updated><title type='text'>Eats 1011 Lecture 1</title><content type='html'>&lt;span xmlns=''&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Course information&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Textbook – 'essentials of meteorology – an invitation to the atmosphere'. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Website -  http://horsehead.ccs.yorku.ca/moodle/login/index.php&lt;span style='text-decoration:underline'&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style='text-decoration:underline'&gt;Introduction&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Earth's radius – 6370km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Tropical cloud tops  ~ 14km&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;What is our atmosphere made of?&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Permanent gases&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;78.08% nitrogen&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;20.95% oxygen&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If there is too much oxygen things would burst into flames&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If there is too little oxygen then we couldn't breathe properly&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;.93% argon&lt;br /&gt;&lt;/li&gt;&lt;li&gt;.0018% neon&lt;br /&gt;&lt;/li&gt;&lt;li&gt;.0005 helium&lt;br /&gt;&lt;/li&gt;&lt;li&gt;.00006 hydrogen&lt;br /&gt;&lt;/li&gt;&lt;li&gt;.000009 xenon&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Mixing ratios by volume = &lt;/li&gt;&lt;li&gt;Composition constant to stand up to ~ 90km &lt;/li&gt;&lt;li&gt;Permanent gases all have very long lifetimes&lt;/li&gt;&lt;li&gt;O&lt;sub&gt;2 &lt;/sub&gt;is consumed by burning fossil fuels but released by photosynthesis, changes by ~ 20 ppmv in 10 years&lt;/li&gt;&lt;li&gt;&lt;em&gt;Ppmv &lt;/em&gt;=     Parts per million volume&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;Variable gases&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;0-4% water vapor &lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Water exists in 3 phases on earth &lt;/div&gt;&lt;ul&gt;&lt;li&gt;vapour&lt;/li&gt;&lt;li&gt;liquid&lt;/li&gt;&lt;li&gt;solid&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;most is in the bottom 3km &lt;/li&gt;&lt;li&gt;latent heat release is important&lt;/li&gt;&lt;li&gt;vapour 'invisible', but absorbs light in near IR and throughout the IR – Greenhouse Gas(GHG)&lt;/li&gt;&lt;li&gt;condensed cloud and water droplets&lt;/li&gt;&lt;li&gt;frozen air ice pellets, crystals and snow&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;.037% carbon dioxide (375 ppm)&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Greenhouse gas (GHG) – 370 ppmv&lt;/li&gt;&lt;li&gt;Increasing at ~.4% / year&lt;/li&gt;&lt;li&gt;16% from 1958 (figure 1.3 ahrens)&lt;/li&gt;&lt;li&gt;32% from beginning of industrial revolution&lt;/li&gt;&lt;li&gt;'lifetime' ~ 250 years&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Sources of CO&lt;sub&gt;2&lt;/sub&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;reverse photosynthesis&lt;/li&gt;&lt;li&gt;&lt;div&gt;O&lt;sub&gt;2&lt;/sub&gt; + sugar / food &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; CO&lt;sub&gt;2&lt;/sub&gt; + H&lt;sub&gt;2&lt;/sub&gt;O&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Wintertime CO&lt;sub&gt;2&lt;/sub&gt; increases&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;decay of vegetation&lt;/li&gt;&lt;li&gt;exhalations of animals / people (burning)&lt;/li&gt;&lt;li&gt;burning of fossil fuels(coal, oil, natural gas)&lt;/li&gt;&lt;li&gt;deforestation (burned or left to rot)&lt;/li&gt;&lt;li&gt;volcanic eruptions&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Sinks&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;removal by photosynthesis&lt;/li&gt;&lt;li&gt;CO&lt;sub&gt;2&lt;/sub&gt; + H&lt;sub&gt;2&lt;/sub&gt;O + Visible light &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; O&lt;sub&gt;2&lt;/sub&gt; + sugar&lt;/li&gt;&lt;li&gt;&lt;div&gt;ocean sinks&lt;/div&gt;&lt;ul&gt;&lt;li&gt;CO&lt;sub&gt;2 &lt;/sub&gt; dissolves in oceans (&lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; 50 times the total atmospheric CO&lt;sub&gt;2&lt;/sub&gt;)&lt;/li&gt;&lt;li&gt;Phytoplankton(tiny plants) fix CO&lt;sub&gt;2&lt;/sub&gt; into organic tissues&lt;/li&gt;&lt;li&gt;Mixes downward in oceans&lt;/li&gt;&lt;li&gt;Summertime CO&lt;sub&gt;2&lt;/sub&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;.00017 methane (1.7ppm)&lt;/div&gt;&lt;ul&gt;&lt;li&gt;CH&lt;sub&gt;4&lt;/sub&gt; = Methane&lt;/li&gt;&lt;li&gt;GHG – 1.7 ppmv&lt;/li&gt;&lt;li&gt;Increasing by .5% per year&lt;/li&gt;&lt;li&gt;Lifetime – 10 years&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;termites (biological activity). Anaerobic (no oxygen) breakdown of plant material by bacteria&lt;/div&gt;&lt;ul&gt;&lt;li&gt;rice paddies&lt;/li&gt;&lt;li&gt;wetlands&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;enteric fermentation&lt;/div&gt;&lt;ul&gt;&lt;li&gt;cows, elephants flatulence&lt;/li&gt;&lt;li&gt;landfills&lt;/li&gt;&lt;li&gt;pipeline loss&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Sinks&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;loss by chemical reactions in the atmosphere&lt;/li&gt;&lt;li/&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;.00003 nitrous oxide (.3 ppm)&lt;/li&gt;&lt;li&gt;&lt;div&gt;.000004 ozone (.04ppm)&lt;/div&gt;&lt;ul&gt;&lt;li&gt;O&lt;sub&gt;3&lt;/sub&gt; - ozone&lt;/li&gt;&lt;li&gt;Most of the ozone is in the stratosphere (20-50km)&lt;/li&gt;&lt;li&gt;Serves as a UV filter (&amp;lt;300nm)&lt;/li&gt;&lt;li&gt;&lt;div&gt;Secondary pollutant &lt;/div&gt;&lt;ul&gt;&lt;li&gt;mixture of NOx and hydrocarbon gases&lt;/li&gt;&lt;li&gt;causes respiratory problems&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;.000001 particles (&lt;em&gt;dust, soot, etc)&lt;/em&gt; (.01 - .15ppm)&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Aerosols&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Natural sources&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Volcanoes, forest fires, blown dust, sea salt, trees&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Anthropogenic sources&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Roads, biomass burning, emissions, reactions in the atmosphere&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Health issues, smaller particles are more lethal&lt;/div&gt;&lt;ul&gt;&lt;li&gt;PM 2.5µm&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;N.B. cloud/rain not normally included as aerosols&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;.00000002 chlorofluorocarbons (&lt;em&gt;CFC's&lt;/em&gt;) (.0002ppm)&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;1.7 ppmv means that for every million air molecules in a volume 1.7 are methane molecules&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;span style='text-decoration:underline'&gt;&lt;strong&gt;Ice cores from Arctic and Antarctic&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Greenland is about 3000 m &lt;/li&gt;&lt;li&gt;Antarctica 3000 m &lt;/li&gt;&lt;li&gt;&lt;div&gt;was our atmosphere always like this?&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Our universe is about 15 billion years old&lt;/li&gt;&lt;li&gt;&lt;div&gt;Solar system formed from rotating debris&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Planets planetsimals asteroids comets&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Earth formed about 4.5 billion years ago &lt;/div&gt;&lt;ul&gt;&lt;li&gt;Pulverized by colliding bodies&lt;/li&gt;&lt;li&gt;Atmosphere of H&lt;sub&gt;2&lt;/sub&gt;, He&lt;/li&gt;&lt;li&gt;Swept away by early solar wind&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;It is likely that we have a secondary or tertiary atmosphere&lt;/li&gt;&lt;li&gt;Likely there was a volcanic outgassing&lt;/li&gt;&lt;li&gt;&lt;div&gt;Emissions from current volcanoes&lt;/div&gt;&lt;ul&gt;&lt;li&gt;80% water&lt;/li&gt;&lt;li&gt;10% CO&lt;sub&gt;2&lt;/sub&gt;&lt;/li&gt;&lt;li&gt;2% nitrogen&lt;/li&gt;&lt;li&gt;Variable% SO&lt;sub&gt;2&lt;/sub&gt;&lt;br /&gt;										&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Cooling&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;water formed oceans&lt;/div&gt;&lt;ul&gt;&lt;li&gt;not much land&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;collisions&lt;/div&gt;&lt;ul&gt;&lt;li&gt;formation of moon&lt;/li&gt;&lt;li&gt;possible cometary source of water&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;sun&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;1bya &lt;/div&gt;&lt;ul&gt;&lt;li&gt;Earth was almost completely frozen&lt;/li&gt;&lt;li&gt;&lt;div&gt;Atmosphere&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Water, CO&lt;sub&gt;2&lt;/sub&gt;, &lt;/div&gt;&lt;ul&gt;&lt;li&gt;completely different from today&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;early atmosphere had no capacity for shielding from UV radiation from the sun&lt;/div&gt;&lt;ul&gt;&lt;li&gt;absorption limits&lt;/li&gt;&lt;li&gt;**&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;So where did our O&lt;sub&gt;2&lt;/sub&gt; atmosphere come from?&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Water photolysis generates O&lt;sub&gt;2&lt;/sub&gt; and ozone (.3µ)&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Photosynthesis&lt;/div&gt;&lt;ul&gt;&lt;li&gt;N(CO&lt;sub&gt;2 &lt;/sub&gt;+ H&lt;sub&gt;2&lt;/sub&gt;O) + sunlight &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; (H&lt;sub&gt;2&lt;/sub&gt;CO)n + nO&lt;sub&gt;2&lt;/sub&gt;(day)&lt;/li&gt;&lt;li&gt;O&lt;sub&gt;2 &lt;/sub&gt;+ H&lt;sub&gt;2&lt;/sub&gt;CO &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; CO&lt;sub&gt;2&lt;/sub&gt; + H&lt;sub&gt;2&lt;/sub&gt;O (night) "burning": energy release&lt;/li&gt;&lt;li&gt;Death/burial of C &lt;span style='font-family:Wingdings'&gt;à&lt;/span&gt; O&lt;sub&gt;2&lt;/sub&gt; remains in atmosphere&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Summary&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Most of the carbon is in sedimentary rocks so that the CO&lt;sub&gt;2&lt;/sub&gt; – N&lt;sub&gt;2&lt;/sub&gt; budget is similar to that of Venus in absolute amounts and to mars in ratio&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4483120384004249880?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4483120384004249880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4483120384004249880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4483120384004249880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4483120384004249880'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2008/01/eats-1011-lecture-1.html' title='Eats 1011 Lecture 1'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8714271207977634829</id><published>2007-07-04T13:40:00.001-05:00</published><updated>2007-07-04T13:40:53.156-05:00</updated><title type='text'>Next Fall!?</title><content type='html'>here's my next fall, i intend on keepin the blog going!&lt;br /&gt;&lt;br /&gt;&lt;a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=dftk7qwn_36fqqwxz"&gt;http://docs.google.com/Doc?id=dftk7qwn_36fqqwxz&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8714271207977634829?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8714271207977634829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8714271207977634829' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8714271207977634829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8714271207977634829'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/07/next-fall_04.html' title='Next Fall!?'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2620926590651429183</id><published>2007-04-14T13:19:00.000-05:00</published><updated>2007-05-28T15:33:18.991-05:00</updated><title type='text'>Lecture 30</title><content type='html'>&lt;div class="RTE"&gt;Sorting an array of strings &lt;/div&gt;&lt;div class="RTE"&gt;for strings you can't use &amp;lt; , &amp;gt;&lt;br /&gt;there exists a method called compareTo() which returns an integer &lt;/div&gt;&lt;div class="RTE"&gt;String x;&lt;br /&gt;String y;&lt;br /&gt;x.compareTo(y); &lt;/div&gt;&lt;div class="RTE"&gt;returns a negative number if x &amp;lt; y&lt;br /&gt;returns zero if x == y&lt;br /&gt;returns a positive number if x &amp;gt; y &lt;/div&gt;&lt;div class="RTE"&gt;String implements the comparable interface &lt;/div&gt;&lt;div class="RTE"&gt;public interface Comparable&lt;br /&gt;{&lt;br /&gt;public int compareTo(Object in);&lt;br /&gt;} &lt;/div&gt;&lt;div class="RTE"&gt;Any class that implements comparable is strongly suggested to do it as follows &lt;/div&gt;&lt;div class="RTE"&gt;1. Total Ordering &lt;/div&gt;&lt;div class="RTE"&gt;- if a.compareTo(b) == 0;&lt;br /&gt;then b.compareTo(a) == 0; (reflexive)&lt;br /&gt;&lt;br /&gt;- if a.compareTo(b) &amp;lt;= 0;&lt;br /&gt;then b.compareTo(a) &amp;gt;= 0; (antisymmetric)&lt;br /&gt;&lt;br /&gt;- if a.compareTo(b) &amp;lt;= 0 and b.compareTo(c) &amp;lt;= 0&lt;br /&gt;then a.compareTo(c) &amp;lt;= 0 (transitive)&lt;br /&gt;&lt;br /&gt;a.compareTo(b) is defined for all a,b (Total)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. If you implement equals() then if a.compareTo(b) == 0;&lt;br /&gt;then a.equals(b) == true&lt;br /&gt;and vice versa&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Searching a sorted list &lt;/div&gt;&lt;div class="RTE"&gt;Sorted list searching can be done recursively with the divide and conquer strategy &lt;/div&gt;&lt;div class="RTE"&gt;&lt;br /&gt;Strategy&lt;br /&gt;- split the list in half&lt;br /&gt;- Let s represent the list item at the split point &lt;/div&gt;&lt;div class="RTE"&gt;if list has size &amp;gt; 1 &lt;/div&gt;&lt;div class="RTE"&gt;if s = i, return index of s&lt;br /&gt;if s &amp;gt; i, search the list segment with smaller values&lt;br /&gt;if s &amp;lt; i, search the list segment with larger values &lt;/div&gt;&lt;div class="RTE"&gt;if list has size 1 &lt;/div&gt;&lt;div class="RTE"&gt;if s = i, return index of s&lt;br /&gt;otherwise i is not in the list&lt;br /&gt;eg/ return -1&lt;/div&gt;&lt;br /&gt;&lt;a href="http://g.msn.com/8HMAENCA/2731??PS=47575" target="_top"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2620926590651429183?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2620926590651429183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2620926590651429183' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2620926590651429183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2620926590651429183'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/sorting-array-of-strings-for-strings.html' title='Lecture 30'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8013000800236965000</id><published>2007-04-03T11:34:00.000-05:00</published><updated>2007-04-03T11:39:07.291-05:00</updated><title type='text'>Lecture 29</title><content type='html'>&lt;u&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;QuickSort&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;somewhat trickier than &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;MergeSort&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;join is trivial&lt;/li&gt;&lt;li&gt;all the action happens in split&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;QuickSort&lt;/span&gt; , split sorts the elements into bins&lt;/li&gt;&lt;li&gt;all the list elements less than the given number is the 'pivot'&lt;/li&gt;&lt;li&gt;all the list elements Greater than a given number&lt;/li&gt;&lt;li&gt;all list elements equal to the pivot&lt;/li&gt;&lt;li&gt;choose the pivot arbitrarily from one of the list elements&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;eg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;493872&lt;br /&gt;&lt;br /&gt;choose 4 as pivot&lt;br /&gt;&lt;br /&gt;low - 3,2&lt;br /&gt;high - 9,8,7&lt;br /&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;pivot&lt;/span&gt; - 4&lt;br /&gt;&lt;br /&gt;concatenate the list in order&lt;br /&gt;&lt;br /&gt;sort(low)&lt;br /&gt;sort(pivot + high)&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_5"&gt;pivot&lt;/span&gt; list is guaranteed to have at least one element(the pivot)&lt;/li&gt;&lt;li&gt;i want both split lists to be smaller than the initial list&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;ol&gt;&lt;li&gt;low list is non empty&lt;/li&gt;&lt;ol&gt;&lt;li&gt;split between low and pivot&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;if low is empty but high is not&lt;/li&gt;&lt;ol&gt;&lt;li&gt;split between &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;pivot&lt;/span&gt; and high&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;if both low and high are empty then split &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;somewhere&lt;/span&gt; in middle of pivot&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8013000800236965000?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8013000800236965000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8013000800236965000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8013000800236965000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8013000800236965000'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/lecture-29.html' title='Lecture 29'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6731410291978329286</id><published>2007-04-03T11:14:00.000-05:00</published><updated>2007-04-03T11:33:51.406-05:00</updated><title type='text'>Lecture 28</title><content type='html'>&lt;u&gt;Sorting&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A fundamental task of computer science&lt;/li&gt;&lt;li&gt;given an array , put the array in order&lt;/li&gt;&lt;/ul&gt;int a[]= {3,9,0,2,6}&lt;br /&gt;sort(a);&lt;br /&gt;a=0,2,3,6,9&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Sorting Strategies&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Bubble Sort&lt;/li&gt;&lt;ul&gt;&lt;li&gt;take the unsorted array and start at the top&lt;/li&gt;&lt;li&gt;traverse the list until you find an element out of order&lt;/li&gt;&lt;li&gt;using pairwise exchanges move the out of order element toward the top of the list until it is in order&lt;/li&gt;&lt;li&gt;continue until the end of the list&lt;/li&gt;&lt;li&gt;once an out of order element is found we float it to the correct position&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;39026&lt;/li&gt;&lt;li&gt;30926&lt;/li&gt;&lt;li&gt;03926&lt;/li&gt;&lt;li&gt;03296&lt;/li&gt;&lt;li&gt;02396&lt;/li&gt;&lt;li&gt;02369&lt;/li&gt;&lt;/ol&gt;Divide and Conquer Sorting&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;nobody uses bubblesort for anything serious&lt;/li&gt;&lt;li&gt;better methods:&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;mergesort&lt;/li&gt;&lt;li&gt;quicksort&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;if the list is of size &gt; 1 then&lt;/li&gt;&lt;ol&gt;&lt;li&gt;divide the list into two sublists&lt;/li&gt;&lt;li&gt;sort each sublist&lt;/li&gt;&lt;li&gt;join the two sublists&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;else&lt;/li&gt;&lt;ol&gt;&lt;li&gt;do nothing&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;these are recursive sorting algorithms&lt;/li&gt;&lt;li&gt;all the actio nhappens in the splitting and joining&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public static void Sort(int[]a, int begin, int end)&lt;br /&gt;//sorts the subvector of 'a' from beginning to end inclusive&lt;br /&gt;{&lt;br /&gt;if (end - begin &gt; 0)&lt;br /&gt;{&lt;br /&gt;int S = split(a,beginning,end)&lt;br /&gt;sort(a,begin,S);&lt;br /&gt;sort(a,S+1,end;&lt;br /&gt;join(a,begin,S,end)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;MergeSort&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;split is simple&lt;/li&gt;&lt;li&gt;join is complicated&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;QuickSort&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;split is complicated&lt;/li&gt;&lt;li&gt;join is simple&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;MergeSort&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;ul&gt;&lt;li&gt;Split&lt;/li&gt;&lt;ul&gt;&lt;li&gt;splits the list down the middle&lt;/li&gt;&lt;li&gt;returns (begin + end )/ 2&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Join&lt;/li&gt;&lt;ul&gt;&lt;li&gt;two sorted Lists&lt;/li&gt;&lt;li&gt;merge them in order&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;038249&lt;br /&gt;038   249&lt;br /&gt;0&lt;2&lt;br /&gt;2&lt;3&lt;br /&gt;3&lt;4&lt;br /&gt;4&lt;8&lt;br /&gt;8&lt;9&lt;br /&gt;023489&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;42091&lt;br /&gt;&lt;br /&gt;420:91&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(102, 102, 0);"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;2&lt;/span&gt;&lt;/span&gt;:&lt;span style="color: rgb(51, 0, 153);"&gt;0&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;4&lt;/span&gt;:&lt;span style="color: rgb(0, 102, 0);"&gt;2&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;4 &lt;/span&gt;       //done&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;2      &lt;/span&gt;  //done&lt;/li&gt;&lt;ul&gt;&lt;li&gt;join(&lt;span style="color: rgb(0, 102, 0);"&gt;2&lt;/span&gt;,&lt;span style="color: rgb(102, 0, 0);"&gt;4&lt;/span&gt;)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;24&lt;/li&gt;&lt;ul&gt;&lt;li&gt;join(24,&lt;span style="color: rgb(0, 0, 102);"&gt;0&lt;/span&gt;)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;024&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;9&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;1&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;9&lt;/span&gt;    //done&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;1  &lt;/span&gt;  //done&lt;/li&gt;&lt;ul&gt;&lt;li&gt;join(&lt;span style="color: rgb(255, 153, 0);"&gt;9&lt;/span&gt;,&lt;span style="color: rgb(255, 0, 0);"&gt;1&lt;/span&gt;)&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;ul&gt;&lt;li&gt;19&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;join(024,91)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;01249&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6731410291978329286?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6731410291978329286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6731410291978329286' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6731410291978329286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6731410291978329286'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/lecture-28.html' title='Lecture 28'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8343156505904908443</id><published>2007-04-03T10:58:00.000-05:00</published><updated>2007-04-03T11:14:08.567-05:00</updated><title type='text'>Lecture 27</title><content type='html'>&lt;u&gt;Stacks and queues&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;best implemented with linked lists&lt;/li&gt;&lt;li&gt;trying to implement with arrays or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;arraylists&lt;/span&gt; is not &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;feasible&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Doubly Linked Lists&lt;br /&gt;&lt;/u&gt;&lt;ul&gt;&lt;li&gt;in a double linked list keep track of &lt;/li&gt;&lt;ul&gt;&lt;li&gt;head&lt;/li&gt;&lt;li&gt;next pointer in each node&lt;/li&gt;&lt;li&gt;tail&lt;br /&gt;&lt;/li&gt;&lt;li&gt;previous pointer of each node&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;DoubleLinkedList&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;ListNode&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myObject&lt;/span&gt; item;&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;ListNode&lt;/span&gt; next;&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;ListNode&lt;/span&gt; prev;&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;ListNode&lt;/span&gt; {...}&lt;br /&gt;}&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;addNode&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;MyObject&lt;/span&gt;, int)&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;delNode&lt;/span&gt;(int)&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;public&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;myObject&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;getData&lt;/span&gt;(int)&lt;br /&gt;&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;addNodeToHead&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;MyObject&lt;/span&gt; a)&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;addNodeToTail&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;MyObject&lt;/span&gt; b)&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;void&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;delNodeFromHead&lt;/span&gt;()&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;delNodeFromTail&lt;/span&gt;()&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;MyObject&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;getDataFromHead&lt;/span&gt;()&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;MyObject&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;getDataFromTail&lt;/span&gt;()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;u&gt;Adding a Node to A Position&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;//&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;ListNode&lt;/span&gt; c = a.next;&lt;br /&gt;b.next = a.next;&lt;br /&gt;b.prev = a;&lt;br /&gt;(a.next).prev = b;&lt;br /&gt;a.next = b&lt;br /&gt;//c.prev = b;&lt;br /&gt;if (a==tail)&lt;br /&gt;{tail=b;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;More Formally&lt;br /&gt;&lt;br /&gt;//&lt;span style="font-family:courier new;"&gt;Check whether a exists&lt;br /&gt;&lt;br /&gt;if (a != null)&lt;br /&gt;{&lt;br /&gt;b.next = a.next;&lt;br /&gt;b.prev = a;&lt;br /&gt;a.next = b;&lt;br /&gt;if (a==tail){tail = b;}&lt;br /&gt;else{&lt;br /&gt;(b.next).prev = b&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;u&gt;Deleting a Node From a Given Position&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if(a.next)!= null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if (a.next = tail)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{a.next = null;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;tail = a}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;else{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;a.next = (a.next).next&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(a.next).prev = a;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Doubly linked list with stacks and queues&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;Stack&lt;/u&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;add&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;addNodeToHead&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;MyObject&lt;/span&gt;)&lt;/li&gt;&lt;li&gt;delete&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;getDataFromHead&lt;/span&gt;()&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;delNodeFromHead&lt;/span&gt;()&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;u&gt;Queue&lt;/u&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;add&lt;/span&gt; a&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;addNodeToHead&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;MyObject&lt;/span&gt;)&lt;/li&gt;&lt;li&gt;delete / leave&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;getDataFromTail&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;delNodeFromTail&lt;/span&gt;()&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8343156505904908443?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8343156505904908443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8343156505904908443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8343156505904908443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8343156505904908443'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/lecture-27.html' title='Lecture 27'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5915262429276006144</id><published>2007-04-03T10:49:00.000-05:00</published><updated>2007-04-03T10:58:48.148-05:00</updated><title type='text'>Lecture 26</title><content type='html'>&lt;u&gt;Linked Lists Continued&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Node Inner Classes&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;ListNode&lt;/span&gt; has no use or meaning apart from the linked list&lt;/li&gt;&lt;li&gt;our existing definition opens the list to privacy leaks&lt;/li&gt;&lt;li&gt;a careless application programmer could get a reference and change it&lt;/li&gt;&lt;li&gt;make &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;ListNode&lt;/span&gt; an inner class within the 'linked list' class&lt;/li&gt;&lt;ul&gt;&lt;li&gt;advantages&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;eliminates privacy leaks&lt;/li&gt;&lt;li&gt;simplifies &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;LinkedList&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;disadvantages&lt;/li&gt;&lt;ul&gt;&lt;li&gt;reduces flexibility&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;LinkedList&lt;/span&gt; inner&lt;br /&gt;{&lt;br /&gt;private class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;ListNode&lt;/span&gt; // inner class&lt;br /&gt;{&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myObject&lt;/span&gt; item;&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;ListNode&lt;/span&gt; next;&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;ListNode&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;MyObject&lt;/span&gt; item, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;ListNode&lt;/span&gt; next) { ... }&lt;br /&gt;}&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;listNode&lt;/span&gt; head; ...}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;myObject&lt;/span&gt; as a generic&lt;/li&gt;&lt;ul&gt;&lt;li&gt;linked lists with generics&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;LinkedList&lt;/span&gt; inner &lt;t&gt; //good&lt;/t&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;private class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;ListNode&lt;/span&gt;&lt;t&gt; /** this is good, but this alone does not &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;suffice&lt;/span&gt; */&lt;/t&gt;&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private T item;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;ListNode&lt;/span&gt; next; // bad&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;ListNode&lt;/span&gt;&lt;t&gt; next; //good&lt;br /&gt;&lt;br /&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;use the generic type parameter firstly with the outer class as well as the inner class&lt;/li&gt;&lt;li&gt;use the generic type parameter with every declaration of the generic object.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5915262429276006144?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5915262429276006144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5915262429276006144' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5915262429276006144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5915262429276006144'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/lecture-26.html' title='Lecture 26'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5727512875231472693</id><published>2007-04-03T10:42:00.000-05:00</published><updated>2007-04-03T10:58:34.440-05:00</updated><title type='text'>Lecture 25</title><content type='html'>&lt;u&gt;Recursion&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Stack&lt;/li&gt;&lt;ul&gt;&lt;li&gt;space for parameters / local values/ return values&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;indirect recursion&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a method which calls iteself with different parameters&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;recursion&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a method which calls itself within itself&lt;/li&gt;&lt;ul&gt;&lt;li&gt;if this is done wrong you get a stack overflow error&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int fact(int n)&lt;br /&gt;{&lt;br /&gt;//base case&lt;br /&gt;&lt;br /&gt;if (n == 1) { return n}&lt;br /&gt;return n * fact(n-1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;famous recursive methods&lt;/li&gt;&lt;ul&gt;&lt;li&gt;binary search&lt;/li&gt;&lt;li&gt;mergesort&lt;/li&gt;&lt;li&gt;quick sort&lt;/li&gt;&lt;li&gt;towers of hanoi&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int bSearch(int[]A, int key, int l, int r)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;// base case&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if (l&gt;r) return -(l + 1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int m = (l + r) / 2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if (A[m] == key ) return m;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if (A[m] &lt; face="courier new"&gt;return bSearch( A, key, m+1, r)&lt;br /&gt;return bSearch(A, key, L, m-1);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;these were the notes i got when turnpin was in class, he doesn't write on the board too often so i hope this helps.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5727512875231472693?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5727512875231472693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5727512875231472693' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5727512875231472693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5727512875231472693'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/04/lecture-25.html' title='Lecture 25'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6138236636389936498</id><published>2007-03-20T09:07:00.001-05:00</published><updated>2007-03-21T10:58:28.929-05:00</updated><title type='text'>LabTest 3 Impressions</title><content type='html'>Hey Guys,&lt;br /&gt;I wrote the test yesterday, relatively hard, wish i studied JUST linked lists instead of the gui and recursion.&lt;br /&gt;turns out the only thing on the test was linked lists and generic class&lt;br /&gt;the test before that (Monday) did linked list with an equals() method..&lt;br /&gt;&lt;br /&gt;I found it pretty misleading of Andrew and Turpin to tell us it would cover everything when it ended up covering linked lists specifically. &lt;br /&gt;worries me quite alot, because now i have no idea if i should believe them about exam materials, etc. &lt;br /&gt;&lt;br /&gt;anyways we had to make a listNode class and a LinkedList class&lt;br /&gt;make them work&lt;br /&gt;using a generic object to carry data&lt;br /&gt;then make a test program which proves that it works, using string and integer values. &lt;br /&gt;&lt;br /&gt;later&lt;br /&gt;Jake&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6138236636389936498?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6138236636389936498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6138236636389936498' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6138236636389936498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6138236636389936498'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/labtest-3-impressions.html' title='LabTest 3 Impressions'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2172082565861533876</id><published>2007-03-15T10:28:00.000-05:00</published><updated>2007-03-15T10:36:25.066-05:00</updated><title type='text'>Lecture 24</title><content type='html'>&lt;u&gt;Linked List&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;data structure containing nodes&lt;/li&gt;&lt;li&gt;each node points to the node after it&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Adding nodes to the middle&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;find the index of the node prior to the one you must add&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int position = &lt;span style="font-style: italic;"&gt;i&lt;/span&gt; // position where the new node gives&lt;br /&gt;ListNode a = FindNum(head, position - 1);&lt;br /&gt;ListNode b = new ListNode();//new object&lt;br /&gt;b.setNext(a.getNext()); // 1&lt;br /&gt;a.setNext(b); //2&lt;br /&gt;&lt;br /&gt;adding position 0 = creating a new head&lt;br /&gt;&lt;br /&gt;listNode b = new ListNode();&lt;br /&gt;b.setNext(head);&lt;br /&gt;head = b;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;u&gt;Deleting Elements&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;deletion involves reordering next pointers&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ListNode a = findNum(head, position - 1);&lt;br /&gt;a.setNext((a.getNext()).getNext());&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;object must not be null&lt;/li&gt;&lt;li&gt;a.getNext must not be null&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Linked List as Object&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public class LinkedList&lt;br /&gt;{&lt;br /&gt;private ListNode head;&lt;br /&gt;public LinkedList(ListNode head);&lt;br /&gt;public LinkedList()&lt;br /&gt;public ListNode findEnd()&lt;br /&gt;public ListNode findNum()&lt;br /&gt;public void addNode(ListNode, newNode, int position)&lt;br /&gt;public void delNode(int position)&lt;br /&gt;public void addNodeToEnd(Listnode, NewNode)&lt;br /&gt;public int getSize()&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2172082565861533876?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2172082565861533876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2172082565861533876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2172082565861533876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2172082565861533876'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/lecture-24.html' title='Lecture 24'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4238783716353040972</id><published>2007-03-13T13:02:00.000-05:00</published><updated>2007-03-13T13:04:42.881-05:00</updated><title type='text'>Java Calculator GUI Lab</title><content type='html'>hey guys,&lt;br /&gt;finally finished it and it works fine.. if you want some simpler code then what i'd seen on the other forum ... use mine.&lt;br /&gt;&lt;br /&gt;i did all of this straight from the lecture notes so there shouldn't be anything too confusing&lt;br /&gt;but i will admit it took me a WHILE to get this working.. rusty i guess.. heh..&lt;br /&gt;later&lt;br /&gt;Jake&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import javax.swing.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import java.awt.FlowLayout;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import java.awt.event.ActionListener;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import java.awt.event.ActionEvent;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import java.awt.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;import javax.swing.JFrame ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public class MenuJFrame&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;extends JFrame&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;implements ActionListener&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        public static final int WIDTH = 600;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        public static final int HEIGHT = 400;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // without putting these here, they are unaccessable by the actionlistener &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        private JPanel westPanel;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        private JPanel eastPanel;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        private JTextField one;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        private JTextField two;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        private JTextField answer;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        public MenuJFrame() &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //main window&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                super("Java Calculator");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                this.setSize(WIDTH,HEIGHT);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                 this.setLayout(new GridLayout(0,2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //west panel&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                westPanel = new JPanel();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                westPanel.setLayout(new GridLayout(3,0));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                this.add(westPanel);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         //east panel&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                eastPanel = new JPanel();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                eastPanel.setLayout(new GridLayout(4,0));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                this.add(eastPanel);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //text fields&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                one = new JTextField(30); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                two = new JTextField(30);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                westPanel.add(one);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                westPanel.add(two);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //answer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                answer = new JTextField("0.0");&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //non-editable text field&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                answer.setEditable(false);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                westPanel.add(answer);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //buttons for east&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                JButton add = new JButton("+"); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                JButton subtract = new JButton("-");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                JButton multiply = new JButton("*");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                JButton divide = new JButton("/");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //add buttons to eastPanel &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                eastPanel.add(add);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                add.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                eastPanel.add(subtract);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                subtract.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                 eastPanel.add(multiply);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                multiply.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                eastPanel.add(divide) ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                divide.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //Menu Bar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //create a new menubar , this is ONLY the grey bar at the top w/ nothing in it!!! &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenuBar myMenuBar = new JMenuBar();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //this.setJMenuBar is a method which auto positions the menu bar @ the top&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        this.setJMenuBar(myMenuBar);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //create two fields,  File and Clear. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenu File = new JMenu("File");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenu Clear = new JMenu("Clear");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //create a menuItem quit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenuItem quit = new JMenuItem("Quit");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         //add action listener to quit, so the program quits when clicked&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        quit.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // add quit to the file menu&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        File.add(quit);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //create menu items for clearing the fields &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenuItem clearA = new JMenuItem("Clear A");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenuItem clearB = new JMenuItem("Clear B");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        JMenuItem wipe = new JMenuItem("Clear All");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //add action listeners for each &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        clearA.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        clearB.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        wipe.addActionListener(this);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // add all three menu items to the menu 'Clear'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        Clear.add(clearA); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        Clear.add(clearB);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        Clear.add(wipe);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // add file and clear to the menu bar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        myMenuBar.add(File);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        myMenuBar.add(Clear);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                //ActionListener&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                public void actionPerformed(ActionEvent e)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        String cmd = e.getActionCommand();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //if the button is '+' then add the two fields and display answer in bottom box &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "+")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        answer.setText((Double.toString((Double.parseDouble(one.getText())) + (Double.parseDouble(two.getText())))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //if the button is '-' then subtract the two fields and display answer in bottom box &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "-")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        answer.setText((Double.toString((Double.parseDouble(one.getText())) - (Double.parseDouble(two.getText())))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //if the button is '*' then multiply the two fields and display answer in bottom box &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "*")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        answer.setText((Double.toString((Double.parseDouble(one.getText())) * (Double.parseDouble(two.getText())))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //if the button is "/" then divide the two fields and display answer in bottom box &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "/")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        answer.setText((Double.toString((Double.parseDouble(one.getText())) / (Double.parseDouble(two.getText())))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        //if button is "Quit" then close the program &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "Quit")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        System.exit(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // if button is 'Clear A' then clear A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "Clear A")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         one.setText("");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // if button is 'Clear B' then clear B&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "Clear B")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        two.setText("");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        // if button is 'Clear All' then clear all fields and leave  0.0 in the answer field&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if (cmd == "Clear All")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        one.setText("");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        two.setText("");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        answer.setText("0.0");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public class JavaCalculator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        public static void main(String[] args)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                MenuJFrame MyWindow = new MenuJFrame();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                MyWindow.setVisible (true);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4238783716353040972?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4238783716353040972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4238783716353040972' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4238783716353040972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4238783716353040972'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/import-javax.html' title='Java Calculator GUI Lab'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5753001224838175643</id><published>2007-03-12T11:33:00.000-05:00</published><updated>2007-03-12T11:34:16.516-05:00</updated><title type='text'>Lab 4 and 5</title><content type='html'>Post your ideas / code / questions for these labs here&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5753001224838175643?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5753001224838175643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5753001224838175643' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5753001224838175643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5753001224838175643'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/lab-4-and-5.html' title='Lab 4 and 5'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4557094875008837276</id><published>2007-03-09T14:52:00.000-05:00</published><updated>2007-03-09T15:02:14.897-05:00</updated><title type='text'>Lecture 23</title><content type='html'>&lt;u&gt;Linked Lists&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;alternative method for producing an array of arbitrary size&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a collection of objects of the same type&lt;/li&gt;&lt;li&gt;contained in the wrapper object, which points (or contains a reference) to the next object in the list&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;declare public class myObject&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class ListNode&lt;br /&gt;{&lt;br /&gt;private myObject item;&lt;br /&gt;private ListNode next;&lt;br /&gt;public ListNode(){...}&lt;br /&gt;public ListNode getNext() {return next}&lt;br /&gt;public void setNext(ListNode next) {this.next = next}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;initially the list is empty&lt;/li&gt;&lt;ul&gt;&lt;li&gt;ListNode head = null;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;add elements to the end as required&lt;/li&gt;&lt;ul&gt;&lt;li&gt;first element:&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;head =  new ListNode();  /*head points to head of chain*/&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;every subsequent slement&lt;/li&gt;&lt;ul&gt;&lt;li&gt;let ListNode tail be reference to the last element in the list&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;ul&gt;&lt;li&gt;tail.setNext(new ListNode(...));&lt;/li&gt;&lt;li&gt;tail = tail.getNext(); // not mandatory to keep track of tail&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;if the list is empty then the head must be 'null'&lt;/li&gt;&lt;li&gt;next pointer in the last element must be null&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Transversing the List&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Items are arranged in order&lt;/li&gt;&lt;ul&gt;&lt;li&gt;the only way to get something from the list is to first access all previous elements&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;Example - &lt;span style="font-style: italic;"&gt;retrieve the ith element&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;pass through i next pointers to find the one you want&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ListNode = head;&lt;br /&gt;int j;&lt;br /&gt;for (j=0; (j&lt;i)&amp;&amp;(n n="n.getNext()}"&gt;&lt;/i)&amp;&amp;amp;(n&gt;&lt;/span&gt;&lt;br /&gt;Example -  &lt;span style="font-style: italic;"&gt;find the last element&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ListNode n = head;&lt;br /&gt;if (n != null)&lt;br /&gt;{&lt;br /&gt;while (n.getNext() ! = null)&lt;br /&gt;{n = n.getNext() }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4557094875008837276?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4557094875008837276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4557094875008837276' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4557094875008837276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4557094875008837276'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/lecture-23.html' title='Lecture 23'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6125049912059350842</id><published>2007-03-09T14:35:00.000-05:00</published><updated>2007-03-09T14:52:16.952-05:00</updated><title type='text'>Lecture 22</title><content type='html'>&lt;u&gt;Generic Methods&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;method with a type parameter&lt;/li&gt;&lt;ul&gt;&lt;li&gt;independent of a generic class&lt;/li&gt;&lt;li&gt;can be used in a non-generic class&lt;/li&gt;&lt;li&gt;can be used in a generic class with a different type parameter&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class myClass&lt;br /&gt;{&lt;br /&gt;public&lt;t&gt; void myMethod(T x)&lt;br /&gt;{&lt;br /&gt;System.out.println(x);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/t&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;syntax for calling the method&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;myClass m = new myClass();&lt;br /&gt;m.&lt;string&gt;myMethod("Hello");&lt;br /&gt;m.&lt;integer&gt;myMethod(6);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;u&gt;Inheritance&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/integer&gt;&lt;/string&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;inheritance is allowed with generics&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class Parent&lt;t&gt;&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class Child&lt;t&gt; extends Parent&lt;t&gt;&lt;br /&gt;{&lt;br /&gt;public class A {...}&lt;br /&gt;public class myGeneric&lt;/t&gt;&lt;/t&gt;&lt;/t&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;t&gt;{...}&lt;br /&gt;myGeneric&lt;b&gt;//&lt;span style="font-weight: bold;"&gt;these two have&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;myGeneric&lt;b&gt;&lt;a&gt;//&lt;span style="font-weight: bold;"&gt;No Relationship&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;&lt;a style="font-family: georgia;"&gt;&lt;u&gt;ArrayList&lt;/u&gt;&lt;br /&gt;&lt;/a&gt;&lt;/t&gt;&lt;/span&gt;&lt;ul style="font-family: georgia;"&gt;&lt;li&gt;&lt;a&gt;ArrayList is a generic class that handles arrays of arbitrary and changeable size&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;must be imported&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;import java.util.ArrayList;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;a&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Create an array of 5 Strings using ArrayList&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ArrayList&lt;string&gt; myList = new ArrayList&lt;string&gt;(5);&lt;br /&gt;//&lt;string&gt; = generic type parameter&lt;br /&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/span&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;&lt;u&gt;Array&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;String[] A  = new String[s];&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;a[3] = "Hello"&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;String b = a[z]&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;int len = a.length&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;a&gt;&lt;u&gt;ArrayList&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;ArrayList&lt;string&gt; myList = new ArrayList&lt;string&gt;(5)&lt;/string&gt;&lt;/string&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;myList.set(3,"hello")&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;String b = myList.get(2);&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a&gt;int len = myList.size()&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;a&gt;Both Indexes start at zero&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;unlike an array you can add elements to an ArrayList&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;a&gt;ArrayList&lt;string&gt; myList = new ArrayList&lt;string&gt;(0);//size is 0&lt;br /&gt;myList.add("x"); // size is now 1&lt;br /&gt;myList.add("y"); // puts y at index 1, size is now 2&lt;br /&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/a&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;a&gt;Can add to the beginning as a middle of the ArrayList&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li style="font-family: courier new;"&gt;&lt;a&gt;myList.add(0, "w")&lt;/a&gt;&lt;/li&gt;&lt;ul style="font-family: courier new; font-style: italic;"&gt;&lt;li&gt;&lt;a&gt;"w" = 0, "x" = 1, "y" = 2&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li style="font-family: courier new;"&gt;&lt;a&gt;myList.add(1,"q")&lt;/a&gt;&lt;/li&gt;&lt;ul style="font-family: courier new; font-style: italic;"&gt;&lt;li&gt;&lt;a&gt;"w"=0, "q" = 1, "x "= 2, "y"= 3&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;b&gt;&lt;a&gt;&lt;br /&gt;&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6125049912059350842?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6125049912059350842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6125049912059350842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6125049912059350842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6125049912059350842'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/lecture-22.html' title='Lecture 22'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7088691845443688002</id><published>2007-03-07T00:19:00.000-05:00</published><updated>2007-03-09T15:02:59.805-05:00</updated><title type='text'>Lecture 21</title><content type='html'>&lt;div class="Section1"&gt;   &lt;p class="MsoNormal"&gt;     Generic programming&lt;br /&gt;    public class x&lt;br /&gt;    {&lt;br /&gt;    private String s;&lt;br /&gt;    public x(String s){this.s = s;}&lt;br /&gt;    public String getS(){return s;}&lt;br /&gt;    }&lt;br /&gt;    if we need many classes with the same function but different instance field type.&lt;br /&gt;    we can&lt;br /&gt;    1. declare them all individually&lt;br /&gt;    2. use a generic class(better)&lt;br /&gt;   &lt;br /&gt;    a generic is a class that takes a type as a parameter&lt;br /&gt;   &lt;br /&gt;    public class x &amp;lt;T&amp;gt;&lt;br /&gt;    {&lt;br /&gt;    private T s;&lt;br /&gt;    public x(T s){this.s=s;}&lt;br /&gt;    public T getS(){return s;}&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    x&amp;lt;String&amp;amp;lgt; myX = new x&amp;lt;String&amp;amp;lgt;("hello");&lt;br /&gt;   &lt;br /&gt;    Note:&lt;br /&gt;    -constructor declared in the class as&lt;br /&gt;    public x(......)&lt;br /&gt;   &lt;br /&gt;    but called as x&amp;lt;String&amp;amp;lgt;(....)&lt;br /&gt;    -The type associated with the generic can be any reference type&lt;br /&gt;    (i.e. any object type)&lt;br /&gt;   &lt;br /&gt;    e.g. String, GregorianCalendar, JFrame and so on.&lt;br /&gt;   &lt;br /&gt;    -Cannot use primitives&lt;br /&gt;    e.g. x&amp;lt;int&amp;amp;lgt; myX = new x&amp;lt;int&amp;amp;lgt;(36) is illegal&lt;br /&gt;   &lt;br /&gt;    -There exist "wrapper" subjects for every primitive type.&lt;br /&gt;    int -&amp;amp;lgt; Integer&lt;br /&gt;    char -&amp;lgt; Character&lt;br /&gt;    double -&amp;lgt; Double&lt;br /&gt;    and so on...&lt;br /&gt;   &lt;br /&gt;    x&amp;lt;Integer&amp;amp;lgt; myX = new x&amp;lt;Integer&amp;amp;lgt;(36); is legal&lt;br /&gt;   &lt;br /&gt;    more illegal uses of the type parameter "T"&lt;br /&gt;   &lt;br /&gt;    T myT = new T(); not okay&lt;br /&gt;    T[] myTArray = new T[10]; not okay&lt;br /&gt;   &lt;br /&gt;    cannot create an array of generics.&lt;br /&gt;    x&amp;lt;String&amp;amp;lgt;[] myXarray = new x &amp;lt;String&amp;amp;lgt;[10] is illegal&lt;br /&gt;   &lt;br /&gt;    can a generic take more than one type ?&lt;br /&gt;    the answer is yes.&lt;br /&gt;   &lt;br /&gt;    public class TwoTypeGeneric &amp;lt;FirstType, SecondType&amp;amp;lgt;&lt;br /&gt;    {&lt;br /&gt;    codes here&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    restricting Types&lt;br /&gt;    you may wish to constrain the type parameter as follows&lt;br /&gt;    1.the child of a given class&lt;br /&gt;    2. implements a give interface&lt;br /&gt;    why?&lt;br /&gt;    can use methods associated with the ancestor/interface&lt;br /&gt;    usage: the extends keyword is used for both interfaces and ancestors.&lt;br /&gt;   &lt;br /&gt;    Require that T implements myInterface&lt;br /&gt;   &lt;br /&gt;    public class x&amp;lt;T extends myInterface&amp;amp;lgt;&lt;br /&gt;   &lt;br /&gt;    require that T is a descendant of ancestor&lt;br /&gt;    public class x&amp;lt;T extends ancestor&amp;amp;lgt;&lt;br /&gt;   &lt;br /&gt;    Also legal to require more than one&lt;br /&gt;    at most one is a class and the rest can be interface&lt;br /&gt;    _ use ampersands (&amp;) to be seperator&lt;br /&gt;    T -&amp;amp;amp;lgt; descendant of class B&lt;br /&gt;    implement interface C,D&lt;br /&gt;    public class x&amp;lt;T extends B&amp;amp;C&amp;D&amp;amp;lgt;   &lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7088691845443688002?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7088691845443688002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7088691845443688002' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7088691845443688002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7088691845443688002'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/generic-programming-public-class-x.html' title='Lecture 21'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6843864332384955106</id><published>2007-03-05T17:09:00.000-05:00</published><updated>2007-03-05T17:09:32.344-05:00</updated><title type='text'>Lecture 20</title><content type='html'>&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;u&gt;Menus&lt;/u&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Important classes are&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenuBar&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenu&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenuItem&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;all three of these are children of Component&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;all implement the add() method&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;u&gt;Creating a Menu&lt;/u&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Create a Menubar&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenuBar myMenuBar = new JMenuBar();&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Create menus and add them to the menubar&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenu = new JMenu(“File”);&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;MyMenuBar.add(myMenu);&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Create and add menu items to the menu&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JMenuItem Save = new JMenuItem(“Save”);&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;MyMenu.add(Save);&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Add action listener to each menu item&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Save.addActionListener(this);&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Add menuBar to the JFrame&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;add (myMenuBar);//Bad!!&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Set JMenuBar(myMenuBar); // Good!!&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p style="MARGIN-BOTTOM: 0.14in; MARGIN-LEFT: 0.5in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0.14in; MARGIN-LEFT: 0.5in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;&lt;u&gt;Windows and Inner Classes&lt;/u&gt;&lt;/p&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;For Complicated window components it makes sense to use inner classes&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;Recall:&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public class OuterClass;&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Private class InnerClass&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;A complicated panel within a JFrame&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public class myJframe extends JFrame&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public myJPanel()&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{//appearance of the panel;}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public JFrame()&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Add ( new myJPanel());&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Private class myJPanel extends JPanel implements ActionListener&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public myJPanel()&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in; TEXT-INDENT: 0.5in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;JButton b = new JButton(“Button”);&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in; TEXT-INDENT: 0.5in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;b.addActionListener(this); /* this refers to myJPanel*/&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in; TEXT-INDENT: 0.5in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;add(b);&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in; TEXT-INDENT: 0.5in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;span style="font-family:Courier New, monospace;"&gt;Public void ActionPerformed(ActionEvent e){…}&lt;/span&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;u&gt;Text Field&lt;/u&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JTextField&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;Constructor takes an integer size argument&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;JTextField t = newJTextField(20); /* 20 chars wide*/&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;public String getText()&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;public void setText(String S)&lt;/p&gt;&lt;li&gt;&lt;p style="MARGIN-BOTTOM: 0.14in"&gt;public void setEditable(boolean e)&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="western" style="MARGIN-BOTTOM: 0.14in"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6843864332384955106?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6843864332384955106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6843864332384955106' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6843864332384955106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6843864332384955106'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/03/lecture-20.html' title='Lecture 20'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5247108051290327929</id><published>2007-02-28T12:33:00.000-05:00</published><updated>2007-02-28T12:50:26.974-05:00</updated><title type='text'>Lecture 19</title><content type='html'>&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;JButton&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;myButton&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;JButton&lt;/span&gt;("x");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-family:courier new;" &gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myListener&lt;/span&gt; m = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myListener&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myButton&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;addActionListener&lt;/span&gt;(m);&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/*&lt;/span&gt; can &lt;span style="color: rgb(0, 0, 0);"&gt;be replaced with&lt;/span&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;span style="font-family:courier new;"&gt;below &lt;span style="color: rgb(0, 0, 0);"&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;-------------------------------&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;myButton&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;addActionListener&lt;/span&gt;(new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;myListener&lt;/span&gt;());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;myJFrame&lt;/span&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;super("title of Window");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;JButton&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;myButton&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;JButton&lt;/span&gt;("title of button");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;myButton&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;addActionListener&lt;/span&gt;( new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;myListener&lt;/span&gt;());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What happens when you have &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_17"&gt;multiple&lt;/span&gt; buttons?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;Bad way&lt;/u&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;define different listener classes for each button&lt;/li&gt;&lt;li&gt;register the appropriate class to the appropriate button&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;u&gt;Good way&lt;/u&gt;&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;examine e&lt;/li&gt;&lt;ul&gt;&lt;li&gt;object of type &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;ActionEvent&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;ActionEvent&lt;/span&gt; has a method returning the label of the button pressed&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public String &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;getActionCommand&lt;/span&gt;()&lt;/span&gt;&lt;br /&gt;/* &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_21"&gt;Andrew&lt;/span&gt; drew a picture of two buttons labeled different things then pointed out that when you click the button "one" e.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;getActionCommand&lt;/span&gt; returns "One"*/&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;These implement the interface &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;LayoutManager&lt;/span&gt;&lt;/u&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;BorderLayout&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;FlowLayout&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;GridLayout&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A window (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;JFrame&lt;/span&gt;) is a container&lt;/li&gt;&lt;ul&gt;&lt;li&gt;allowed to contain objects and have layouts&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;a window can be divided into regions using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;LayoutManager&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;each region can be made into a container by declaring it a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;JPanel&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;a panel is a Container&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Declare a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;LayoutManager&lt;/span&gt;&lt;/li&gt;&lt;ol  style="font-family:courier new;"&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;setLayout&lt;/span&gt;(new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;BorderLayout&lt;/span&gt;());&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Add a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;apanel&lt;/span&gt; to as many regions as you want&lt;/li&gt;&lt;ol&gt;&lt;li  style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;JPanel&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;myPanel&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;JPanel&lt;/span&gt;();&lt;/li&gt;&lt;li  style="font-family:courier new;"&gt;add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;MyPanel&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;BorderLayout&lt;/span&gt;, North);&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Declare a layout to the panel&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;myPanel.SetLayout(new.FlowLayout());&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5247108051290327929?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5247108051290327929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5247108051290327929' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5247108051290327929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5247108051290327929'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-19.html' title='Lecture 19'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2192734154016378563</id><published>2007-02-26T11:35:00.000-05:00</published><updated>2007-02-28T12:59:46.061-05:00</updated><title type='text'>Lecture 18</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Create the component&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Create a listener&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Create an instance of the  listener&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Add (“register”) the  listener to the component&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Add the component to the JFrame&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;You can skip steps 2 – 4 if  your program doesn’t require an action&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;How does this work?&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Create a visual interface&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;A JFrame&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;A button&lt;/p&gt;  &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Then implement a listener&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;this is the code which you   wish to perform once the button Is pressed&lt;/p&gt;  &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;register the listener to the  button&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;when the button is pressed    &lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Java calls ActionPerformed&lt;/p&gt;   &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;You do not call    ActionPerformed&lt;/p&gt;    &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;ActionPerformed is an    automation in Java&lt;/p&gt;   &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Registration tells Java to call  it when the button is pressed&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;And then reads the listener&lt;/p&gt;  &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;Labels&lt;/u&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;can add a line of text using  JLabel component&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;create a component&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;JLabel   MyLabel = new JLabel(“My Label”);&lt;/span&gt;&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Skip&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Skip&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Skip&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Add the component to the   JFrame&lt;/p&gt;   &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindow.add(MyLabel);&lt;/span&gt;&lt;/p&gt;   &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;Layouts&lt;/u&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;We require a way to arrange  multiple objects within a window&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Java technique which  accomplishes that is the &lt;b&gt;&lt;i&gt;layout&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;BorderLayout&lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;GridLayout&lt;/p&gt;   &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;FlowLayout&lt;/p&gt;   &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;JFrame contains a method  setLayout()&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindow.setLayout(Layout  l);&lt;/span&gt;&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Executing this sets the layout  of the window to the layout object l.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="color:#ff0000;"&gt;Andrew is  not sure that setLayout take a Layout as its param, he will find out  for next class&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;BorderLayout&lt;/u&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;When Adding a component also  specify a region in which It goes&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindow.add(MyButton,   BorderLayout.North&lt;i&gt;/East/South/West/Center&lt;/i&gt;)&lt;/span&gt;&lt;/p&gt;  &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-left: 1.5in; margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-left: 1.5in; margin-bottom: 0.14in;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#000000;"&gt;&lt;img src="http://docs.google.com/File?id=dftk7qwn_19hjntbb" name="graphics1" align="bottom" border="1" height="138" width="128" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;GridLayout&lt;/u&gt;&lt;/p&gt; &lt;p style="margin-left: 0.5in; margin-bottom: 0.14in;"&gt;GridLayout GL;&lt;/p&gt; &lt;p style="margin-left: 0.5in; margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;GL = new GridLayout (&lt;span style="color:#c0504d;"&gt;2&lt;/span&gt;,&lt;span style="color:#c0504d;"&gt; 3&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-left: 1in; margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;//&lt;span style="color:#c0504d;"&gt;2&lt;/span&gt; = rows, &lt;span style="color:#c0504d;"&gt;3&lt;/span&gt; = columns&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-left: 1in; margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindows.setLayout(GL);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-left: 0.5in; margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;JLabel Label 1 = new JLabel (“1”)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-left: 0.5in; margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindow.add (Label 1);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;Flow Layout&lt;/u&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;flowLayout FL;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;FL = newFlowLayout ();&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;MyWindow.setLayout (FL);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;span style="font-family:courier new;"&gt;// add components&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0.14in;"&gt;&lt;u&gt;Good JFrame Practice&lt;/u&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Up to now, everything has been  done in main&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;This is bad practice because  the window is an object&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;It should be treated as such&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;We are creating a modification  of JFrame&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0.14in;"&gt;Use inheritance&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2192734154016378563?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2192734154016378563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2192734154016378563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2192734154016378563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2192734154016378563'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-18.html' title='Lecture 18'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3266990606599239166</id><published>2007-02-23T12:46:00.000-05:00</published><updated>2007-02-23T12:58:37.612-05:00</updated><title type='text'>Lecture 17</title><content type='html'>&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;JFrame&lt;/span&gt; is the class that handles windows in Java&lt;/li&gt;&lt;ul&gt;&lt;li&gt;import 'javax.Swing.JFrame;&lt;/li&gt;&lt;li&gt;creating a window is equivalent to &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;creating&lt;/span&gt; an object of type &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;JFrame&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;JFrame&lt;/span&gt; has an extensive public interface&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;setSize&lt;/span&gt;(int width, int height)&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;setTitle&lt;/span&gt;(String title)&lt;br /&gt;public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;JFrame&lt;/span&gt;(String title)&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;setVisible&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;boolean&lt;/span&gt; v)&lt;br /&gt;public void add(Component x)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;notice that the program &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;didn&lt;/span&gt;'t end when the window closes by default&lt;/li&gt;&lt;li&gt;default window close behaviour is to hide the window (but not exit the program)&lt;/li&gt;&lt;li&gt;we have to handle the event where the user clicks close&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;setDefaultCloseOperation&lt;/span&gt;(int x)&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;we can use&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;JFrame&lt;/span&gt;.EXIT_ON_CLOSE&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;JFrame&lt;/span&gt;.HIDE_ON_CLOSE&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;JFrame&lt;/span&gt;.DO_NOTHING_ON_CLOSE&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;These are &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;given&lt;/span&gt; integer values (in order) 3,0,1&lt;/li&gt;&lt;ul&gt;&lt;li&gt;do not use these values as Java might change those numbers in an update&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Action Listeners and Action Events&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;each component must register the listener that handles its events&lt;/li&gt;&lt;li&gt;Java interface &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;ActionListener&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;event type is a class called &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;ActionEvent&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a listener you define must implement the interface &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;ActionListener&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;actionPerform&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;ActionEvent&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;Create the component&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;JButton&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;myButton&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;JButton&lt;/span&gt;(" ");&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Write a listener class&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;myListener&lt;/span&gt; implements &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;ActionListener&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;actionPerformed&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;ActionEvent&lt;/span&gt; c)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;li style="font-family: georgia;"&gt;Create an instance of the listener&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;MyListener&lt;/span&gt; m = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;myListener&lt;/span&gt;();&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;li style="font-family: georgia;"&gt;register the listener with the component&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;myButton&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;addActionListener&lt;/span&gt;(m)&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;li style="font-family: georgia;"&gt;add the component to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;JFrame&lt;/span&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;myWindow&lt;/span&gt;.add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;MyButton&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3266990606599239166?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3266990606599239166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3266990606599239166' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3266990606599239166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3266990606599239166'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-17.html' title='Lecture 17'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5980985307560698370</id><published>2007-02-21T12:21:00.000-05:00</published><updated>2007-02-21T12:25:04.623-05:00</updated><title type='text'>Finished Test 2 Impressions</title><content type='html'>Just wrote the test yesterday...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;had to make an&lt;/li&gt;&lt;ul&gt;&lt;li&gt;abstract class&lt;/li&gt;&lt;li&gt;a child extended class from that class&lt;/li&gt;&lt;li&gt;an array which takes in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;args&lt;/span&gt; parameters and inputs them into the class&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;i found it to be somewhat simple&lt;/li&gt;&lt;ul&gt;&lt;li&gt;but the time we had i didn't feel was enough&lt;/li&gt;&lt;li&gt;and Andrew's &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;API&lt;/span&gt; was quite unfinished&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;and seemed to have a typo in a method description in his &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;being given a test that had to support an unfinished &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;API&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;and had to start from scratch&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;was VERY difficult for me to get done&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;still felt the test was fair, for what it tested&lt;/li&gt;&lt;li&gt;but my advice to those who haven't written it&lt;/li&gt;&lt;ul&gt;&lt;li&gt;practice your speed&lt;/li&gt;&lt;li&gt;be sure of your coding practice&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;later&lt;br /&gt;Jake&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5980985307560698370?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5980985307560698370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5980985307560698370' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5980985307560698370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5980985307560698370'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/finished-test-2-impressions.html' title='Finished Test 2 Impressions'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2217164714865820074</id><published>2007-02-21T11:58:00.000-05:00</published><updated>2007-02-21T12:10:42.681-05:00</updated><title type='text'>Lecture 16</title><content type='html'>&lt;ul&gt;&lt;li&gt;polymorphism is a very powerful tool because many related classes can be handled the same way and through the same public interface.&lt;/li&gt;&lt;li&gt;java figures out which overridden method is the public interface to use&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Student&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Undergrad&lt;/li&gt;&lt;li&gt;Graduate&lt;/li&gt;&lt;li&gt;all 'students' have a routine for calculating letter grades&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public string getLetterGrade()&lt;br /&gt;&lt;br /&gt;public void printTranscript(Student s)&lt;br /&gt;{&lt;br /&gt;System.out.println(s.getLetterGrade());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;u - undergraduate&lt;/li&gt;&lt;li&gt;g - graduate student&lt;/li&gt;&lt;li&gt;q - special student&lt;/li&gt;&lt;ul&gt;&lt;li&gt;these are all classes which have getLetterGrade overrides&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;ul&gt;&lt;li&gt;print transcript(u)&lt;/li&gt;&lt;li&gt;print transcript(g)&lt;/li&gt;&lt;li&gt;print transcript(q)&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Polymorphism and Arrays&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;consider an array of students&lt;/li&gt;&lt;ul&gt;&lt;li&gt;conglomeration of undergraduate students, graduate students and others.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;how do we create the array?&lt;/li&gt;&lt;/ul&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;Arrays&lt;/span&gt;     vs.     &lt;span style="color: rgb(255, 102, 102);"&gt;non-arrays&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;Student[] s;                        &lt;span style="color: rgb(255, 102, 102);"&gt;Student S;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;s = new Student[5];      &lt;span style="color: rgb(255, 102, 102);"&gt;  S= new Student(); // not legal&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Graphical User Interfaces (GUI)&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;so for our programs we have started on the first line, gone through every line in sequence, and terminated at the end&lt;/li&gt;&lt;li&gt;windows does not work that way&lt;/li&gt;&lt;li&gt;the programmer doesn't determine the order of events&lt;/li&gt;&lt;li&gt;the program 'listens' for user-generated events and passes them to the event handler&lt;/li&gt;&lt;li&gt;A GUI program consists largely of event handlers that respond to events&lt;/li&gt;&lt;li&gt;you would almost never call event handler methods instead java calls them when the even happens&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2217164714865820074?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2217164714865820074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2217164714865820074' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2217164714865820074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2217164714865820074'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-16.html' title='Lecture 16'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4483379318507127073</id><published>2007-02-19T12:56:00.001-05:00</published><updated>2007-02-19T12:56:21.742-05:00</updated><title type='text'>Lab Test 2 Impressions</title><content type='html'>Here you can post how you felt the test went, give pointers to those who haven't taken it and so on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4483379318507127073?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4483379318507127073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4483379318507127073' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4483379318507127073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4483379318507127073'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lab-test-2-impressions.html' title='Lab Test 2 Impressions'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2615337930256019117</id><published>2007-02-19T12:35:00.001-05:00</published><updated>2007-02-19T12:52:13.339-05:00</updated><title type='text'>Lecture 15</title><content type='html'>&lt;span style="font-style: italic; color: rgb(255, 102, 102);font-size:85%;" &gt;Things to know for the next Lab:&lt;/span&gt;&lt;span style="color: rgb(255, 102, 102);font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(255, 102, 102);"&gt;&lt;span style="font-size:85%;"&gt;Inheritance, Arrays, Interface&lt;br /&gt;&lt;br /&gt;Things to know for the Midterm:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;everything we have covered until this class (Feb 19 2007) is fair game for the midterm&lt;br /&gt;this is unofficially true but the only thing Andrew has told pertaining to Test Content.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;u&gt;Aggregation&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;keeps a reference to an external object&lt;/li&gt;&lt;li&gt;external object outlives the aggregate&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Composition&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;keeps a copy of object it contains&lt;/li&gt;&lt;li&gt;contained object lives and dies with the composition&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Polymorphism and Arrays&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class Parent{}&lt;br /&gt;&lt;br /&gt;public class Child extends Parent{}&lt;br /&gt;&lt;br /&gt;Parent P;&lt;br /&gt;Child c;&lt;br /&gt;c = new Child();&lt;br /&gt;p = c;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;this is legal&lt;br /&gt;&lt;/li&gt;&lt;li&gt;P is a reference to C&lt;/li&gt;&lt;li&gt;P is of type parent&lt;/li&gt;&lt;li&gt;P is a reference to C &lt;span style="font-weight: bold;"&gt;and&lt;/span&gt; is treated like  an object of type Parent&lt;/li&gt;&lt;li&gt;remember&lt;/li&gt;&lt;ul&gt;&lt;li&gt;C inherits all of P's methods&lt;/li&gt;&lt;li&gt;C can use anything inherited from P&lt;/li&gt;&lt;ul&gt;&lt;li&gt;public methods ...etc&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;but when p=c&lt;/li&gt;&lt;ul&gt;&lt;li&gt;p can only access inherited methods from C&lt;/li&gt;&lt;ul&gt;&lt;li&gt;in other words only methods which exist in both classes can be used in p&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;suppose C has an overridden method&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class Parent&lt;br /&gt;{&lt;br /&gt;public void myMethod()&lt;br /&gt;{&lt;br /&gt;System.out.println("parent");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public class Child extends Parent()&lt;br /&gt;{&lt;br /&gt;public void myMethod()&lt;br /&gt;{&lt;br /&gt;System.out.println("child");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;Child c;&lt;br /&gt;Parent p;&lt;br /&gt;c = new Child();&lt;br /&gt;p = c&lt;br /&gt;c.myMethod(); /* prints "child" */&lt;br /&gt;p.myMethod(); /* prints "child" */&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;p.myMethod prints "child"&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this is because java remembers that P started out as C which is type child&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this is called "Late Binding"&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Child c;&lt;br /&gt;Parent p;&lt;br /&gt;c = new Child();&lt;br /&gt;c.myMethod(); /* prints "child" because of overriding*/&lt;br /&gt;p = c;&lt;br /&gt;p.myMethod(); /* prints "child" because of polymorphism / late binding*/&lt;br /&gt;p = new Parent();&lt;br /&gt;p.myMethod(); /* prints "parent" because it is not an object reference anymore*/&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2615337930256019117?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2615337930256019117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2615337930256019117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2615337930256019117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2615337930256019117'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-15.html' title='Lecture 15'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-753220299819826025</id><published>2007-02-14T17:40:00.000-05:00</published><updated>2007-02-25T11:31:49.047-05:00</updated><title type='text'>More On Arrays</title><content type='html'>&lt;u&gt;Review of Arrays&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Declaring&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;double[] &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;testmark&lt;/span&gt;;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Assign Space&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;testMark&lt;/span&gt; = new double[5]&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Use Elements in Array&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;testMark&lt;/span&gt;[3] = 720;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;an array is a table of values stored in memory&lt;/li&gt;&lt;li&gt;the array name (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;testMark&lt;/span&gt;) is a reference to the array, just like object references&lt;/li&gt;&lt;li&gt;to refer the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;ith&lt;/span&gt; member of the array&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;testMark&lt;/span&gt;[i]&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Very Important&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;array &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;indices&lt;/span&gt; start at zero, not one.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;testMark&lt;/span&gt;.length&lt;/li&gt;&lt;ul&gt;&lt;li&gt;length is the keyword to get the length of the array&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;arrays are objects&lt;/li&gt;&lt;ul&gt;&lt;li&gt;they should be treated as such&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;because we can change the elements of an array and &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_8"&gt;because&lt;/span&gt; arrays are objects we have to treat them as mutable objects&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;deep copy, defensive copy&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;look again at &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;testMark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;double[]&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;copyMarks&lt;/span&gt;; // create a copy of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;testMarks&lt;/span&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;copyMarks&lt;/span&gt; = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;testmarks&lt;/span&gt; //BAD!!!&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;both references (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;copyMarks&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;testMarks&lt;/span&gt;) point to the same thing&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_16"&gt;remember&lt;/span&gt; this also happens with object references&lt;/li&gt;&lt;li&gt;how do we create a copy of an array?&lt;/li&gt;&lt;ol&gt;&lt;li&gt;allocate new space&lt;/li&gt;&lt;li&gt;individually &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;copy&lt;/span&gt; elements&lt;/li&gt;&lt;/ol&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;testMark&lt;/span&gt; = new double[5]&lt;br /&gt;int i;&lt;br /&gt;for (i=0, i &lt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;testMark&lt;/span&gt;.length, i++)&lt;br /&gt;{&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;copyMark&lt;/span&gt;[i] = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;testMark&lt;/span&gt;[i];&lt;br /&gt;}&lt;s.length, i=""&gt;&lt;/s.length,&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Arrays are mutable objects which means Defensive copying&lt;/li&gt;&lt;li&gt;copy on object containing an array&lt;/li&gt;&lt;ul&gt;&lt;li&gt;deep copy&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;so i do deep copy test mark&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;testMark&lt;/span&gt; == &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;copyMark&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this is not the same reference&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;unfortunately equals() does not exist for arrays&lt;/li&gt;&lt;li&gt;there exist java utilities for array equals&lt;/li&gt;&lt;ul&gt;&lt;li&gt;java.util.arrays&lt;/li&gt;&lt;ul&gt;&lt;li&gt;equals&lt;/li&gt;&lt;li&gt;fill&lt;/li&gt;&lt;li&gt;sort&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-753220299819826025?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/753220299819826025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=753220299819826025' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/753220299819826025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/753220299819826025'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/more-on-arrays.html' title='More On Arrays'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2975747740191527717</id><published>2007-02-14T17:27:00.000-05:00</published><updated>2007-02-20T12:45:33.681-05:00</updated><title type='text'>Lecture 14</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Midterm Feb 25 2007&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;Command Line Arguments&lt;/u&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public static void main (String[]&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;args&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;}&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;argument passed to main is an ARRAY of STRINGS&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;args&lt;/span&gt; is an array of Strings consisting of arguments typed on the command line when Java was executed&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;console - &lt;/span&gt;java -&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;cp&lt;/span&gt; . &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;ArgsTest&lt;/span&gt; one two three&lt;br /&gt;&lt;ul&gt;&lt;li&gt;that is 3 arguments&lt;/li&gt;&lt;ul&gt;&lt;li&gt;one&lt;/li&gt;&lt;li&gt;two&lt;/li&gt;&lt;li&gt;three&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;"&gt;NOTE: args are seperated by empty spaces, NOT COMMAS, i tested this code myself after class&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;how many parameters?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;args&lt;/span&gt;.length&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;this is useful for automation and for quick input to a program&lt;/li&gt;&lt;li&gt;can you pass array objects to a method as a parameter?&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;yes&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public void method (double[]&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myArray&lt;/span&gt;)&lt;br /&gt;{}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;can you return an array?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;yes&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public double[] method()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;remember to defensively copy&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Aggregates and Compositions&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;composition&lt;/span&gt; is like an aggregate but stronger&lt;/li&gt;&lt;li&gt;here the parts only exist in the context of the whole and vice &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;versa&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a car is not a car without an engine&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;a book is not a book without pages&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;An aggregation relationship&lt;/li&gt;&lt;ul&gt;&lt;li&gt;aggregate does not keep a private copy of its member objects&lt;/li&gt;&lt;li&gt;refers to them by reference&lt;/li&gt;&lt;ul&gt;&lt;li&gt;investments which contain stocks&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class Investment&lt;br /&gt;{&lt;br /&gt;private Stock x;&lt;br /&gt;private int &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;num&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;public class Stock&lt;br /&gt;{&lt;br /&gt;private String name;&lt;br /&gt;private double price;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;who creates the stock?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;investments constructor should not create a stock&lt;/li&gt;&lt;li&gt;should already exist when Investment is created&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;should Investment keep a local copy of the Stock?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;No&lt;/li&gt;&lt;ul&gt;&lt;li&gt;the stock is under outside control&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;stock outlives the Investment and exists outside the Investment&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;this is an aggregation&lt;/li&gt;&lt;li&gt;a composition relationship&lt;/li&gt;&lt;ul&gt;&lt;li&gt;private copies are kept&lt;/li&gt;&lt;li&gt;contained objects do not exist outside of the composition&lt;/li&gt;&lt;li&gt;objects live and die with composition&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;CreditCard&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private String name;&lt;br /&gt;private int &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;cardNum&lt;/span&gt;;&lt;br /&gt;private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;GregorianCalendar&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;dateOfIssue&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;//this is a composition relationship&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2975747740191527717?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2975747740191527717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2975747740191527717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2975747740191527717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2975747740191527717'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-14_14.html' title='Lecture 14'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2014427149387348703</id><published>2007-02-07T12:43:00.000-05:00</published><updated>2007-02-25T11:48:25.741-05:00</updated><title type='text'>Lecture 13</title><content type='html'>&lt;u&gt;Inner Classes&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;an inner class is a class defined within another class&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;outerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;innerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;inner classes provide extra 'class-like' functionality to your class&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;makes your class look self contained&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;inner classes have access to private members of the outer class&lt;/li&gt;&lt;ul&gt;&lt;li&gt;and vice &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;versa&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;inner classes can be made public and are then visible outside of the outer class&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Access&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;outerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private int y;&lt;br /&gt;private int x;&lt;br /&gt;&lt;br /&gt;private class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;innerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private int y;&lt;br /&gt;&lt;br /&gt;public void method()&lt;br /&gt;{x=0 //if no private member in inner class named x&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;if no private member in &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;innerClass&lt;/span&gt; is named x , it can refer to x in the outer class by name&lt;/li&gt;&lt;li&gt;to gain access to the outer class y&lt;/li&gt;&lt;ul&gt;&lt;li&gt;outerClass.this.y&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;outerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private int x;&lt;br /&gt;private int y;&lt;br /&gt;private class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;innerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private int y;&lt;br /&gt;public void method()&lt;br /&gt;{&lt;br /&gt;x = 0; // refers to the &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;outerClass&lt;/span&gt; x&lt;br /&gt;y = 0; //refers to the &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;innerClass&lt;/span&gt; y&lt;br /&gt;outerClass.this.y; // refers to &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;outerClass&lt;/span&gt; y&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;creating a public Object of an inner class type&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;outerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;innerClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;first create an object of type &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;outerClass&lt;/span&gt;&lt;/li&gt;&lt;li&gt;then create an object of type &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;innerClass&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;outerClass&lt;/span&gt; a = new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;outerClass&lt;/span&gt;();&lt;br /&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;outerClass&lt;/span&gt;.&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;innerClass&lt;/span&gt; b = a.new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;innerClass&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Aggregates Compositions and Arrays&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;u&gt;Arrays&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;in undergrad say we want to store the grades for all the term tests instead of just the final raw grade&lt;/li&gt;&lt;li&gt;an array lets us refer the collections of variables of the same type using a single name and number&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Very Important&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Arrays in java always have their first &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_20"&gt;object&lt;/span&gt; at zero (0)&lt;/li&gt;&lt;li&gt;if you don't know the length of an array&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;all arrays have a special public field called 'length'&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;testArray.length&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;Alternative Array Declaration&lt;/li&gt;&lt;ul&gt;&lt;li&gt;(with initialization)&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;double[]testArray = {&lt;span style="font-weight: bold;"&gt;0.0,0.0,0.0,0.0,0.0&lt;/span&gt;}&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;this array has 5 elements&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2014427149387348703?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2014427149387348703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2014427149387348703' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2014427149387348703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2014427149387348703'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-13.html' title='Lecture 13'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-9026473098134247576</id><published>2007-02-05T09:26:00.000-05:00</published><updated>2007-02-05T09:28:28.113-05:00</updated><title type='text'>Lab 3</title><content type='html'>Please Post your ideas for Lab 3 here! I haven't started yet, my labs are on tuesday!&lt;br /&gt;&lt;br /&gt;For Lab Instructions: &lt;a href="http://www.cse.yorku.ca/course_archive/2006-07/W/1030/labs/lab3/"&gt;Click&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-9026473098134247576?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/9026473098134247576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=9026473098134247576' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/9026473098134247576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/9026473098134247576'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lab-3.html' title='Lab 3'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8379286463552059888</id><published>2007-02-02T11:45:00.000-05:00</published><updated>2007-02-02T11:50:35.357-05:00</updated><title type='text'>SSH Tips and Tricks</title><content type='html'>I'm tired of programming in prism, i want to program at home.&lt;br /&gt;&lt;br /&gt;Andrew uses an SSH client in class to mimic a &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;Linux&lt;/span&gt; environment in Windows and to access example files from his login...&lt;br /&gt;&lt;br /&gt;I want to do this, but i don't know how!&lt;br /&gt;&lt;br /&gt;I spoke to Andrew he said any SSH client will work (putty...etc)&lt;br /&gt;and that everything has to be saved and edited at york to do it through that client&lt;br /&gt;&lt;br /&gt;does anyone use SSH at home?&lt;br /&gt;if so can you put the URL for &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;YorkU's&lt;/span&gt; SSH portal in the comments of this post?&lt;br /&gt;as well anything you know about SSH that others will find useful would be great...&lt;br /&gt;&lt;br /&gt;Later&lt;br /&gt;Jake&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8379286463552059888?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8379286463552059888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8379286463552059888' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8379286463552059888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8379286463552059888'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/ssh-tips-and-tricks.html' title='SSH Tips and Tricks'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-7907510881904293551</id><published>2007-02-02T11:34:00.000-05:00</published><updated>2007-02-02T11:45:18.453-05:00</updated><title type='text'>Lecture 12</title><content type='html'>&lt;u&gt;Abstract Classes&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Abstract class is a class that cannot be instantiated&lt;/li&gt;&lt;ul&gt;&lt;li&gt;only its children can be instantiated&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Abstract Method&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a method that is not defined in the abstract class&lt;/li&gt;&lt;ul&gt;&lt;li&gt;only its head is given&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Interfaces&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;can be thought of as an extreme abstract class&lt;/li&gt;&lt;li&gt;used to group together classes with similar features into a 'type'&lt;/li&gt;&lt;li&gt;interfaces contain only abstract method headers&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;no instance fields&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;an interface is a description of how to interact with a group of related classes&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Syntax&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public interface myInterface&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/*any method in here is abstract, it is assumed that it is abstract so you don't have to write the keyword 'abstract'*/&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;public void method(int a);&lt;br /&gt;public int method2();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;any class that implements the interface must override method, and method2&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public class MyClass &lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;implements&lt;/span&gt;&lt;/span&gt; MyInterface&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;private int f;&lt;br /&gt;public void method1(int a)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;System.out.println(a)&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;public int method2()&lt;br /&gt;{&lt;br /&gt;return f;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;you can create objects of type MyClass and treat them as type myInterface if necessary&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public void interfaceMethod(myInterface in, int a)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;int b;&lt;br /&gt;in.method1(a);&lt;br /&gt;b = in.method2();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;it is possible to implement multiple interfaces&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public class MyClass implements interface1, interface2&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* &lt;span style="font-style: italic;"&gt;this would force MyClass to have all methods from both interface before it will compile */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;it is possible to have inheritance within interfaces&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public interface MyInterface&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;public void M1();&lt;br /&gt;public void M2();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public interface myChild &lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;extends&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;myInterface&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;public void M3();&lt;br /&gt;}&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;a class that implements an interface but doesn't override one or more interface methods must be an abstract class&lt;/li&gt;&lt;li&gt;all unimplemented methods are automatically abstract&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-7907510881904293551?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/7907510881904293551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=7907510881904293551' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7907510881904293551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/7907510881904293551'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/02/lecture-12.html' title='Lecture 12'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-5297761037694962741</id><published>2007-01-31T12:38:00.000-05:00</published><updated>2007-01-31T12:58:47.979-05:00</updated><title type='text'>Lecture 11</title><content type='html'>&lt;u&gt;Inheritance&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Objects that inherit features of a parent class can be thought to contain an object of the parent type&lt;/li&gt;&lt;li&gt;all methods and fields of the parent are "inherited"&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Best Practices With Inheritance&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;discard packaging&lt;/li&gt;&lt;li&gt;make all instance fields private&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this means instance fields are not visible to child methods&lt;/li&gt;&lt;li&gt;if you need to access instance fields of the parent from the child use the public interface&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Why Do This?&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;child inherits parent's methods and therefore inherits the public interface&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this simplifies access&lt;/li&gt;&lt;li&gt;and prevents privacy problems via inheritance&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class Parent&lt;br /&gt;{&lt;br /&gt;protected mutable class x;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Child extends Parent&lt;br /&gt;{public mutable class leakyMethod()&lt;br /&gt; {return m;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;u&gt;Constructors&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;form part of the public interface&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class Child extends Parent&lt;br /&gt;{&lt;br /&gt;public child ( ...&lt;span style="font-weight: bold;"&gt;parameters for child / parent ) &lt;/span&gt;&lt;br /&gt;//call parent constructor&lt;br /&gt;super(...&lt;span style="font-weight: bold;"&gt;parameters for parent&lt;/span&gt;)&lt;br /&gt;//assigns child parameter&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;u&gt;Overriding Methods&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Child classes inherit all methods from the parent&lt;/li&gt;&lt;li&gt;child has the option to re-implement these methods&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;called overriding&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;All objects extend type Object by default&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class MyClass [extends Object]&lt;br /&gt;[&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;type object contains several default methods&lt;/li&gt;&lt;ul&gt;&lt;li&gt;equals(), toString(), clone()&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;declaration of an overridden method in the child must be exactly the same as the parent&lt;/li&gt;&lt;ul&gt;&lt;li&gt;same return type&lt;/li&gt;&lt;li&gt;same parameter type&lt;/li&gt;&lt;li&gt;same number of parameters&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;u&gt;Parent&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public int myMethod(double a, int b)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;u&gt;Child&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;public int myMethod(double a, int b)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;if myMethod is overridden in a child class, use 'super.myMethod' to gain access to the parent method&lt;/li&gt;&lt;li&gt;to prevent overriding use 'final'&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Abstract Classes&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a student is either graduate or undergraduate&lt;/li&gt;&lt;ul&gt;&lt;li&gt;there is no 'plain' student&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;so it doesn't make sense to instantiate this class&lt;/li&gt;&lt;li&gt;all students have letter grades&lt;/li&gt;&lt;li&gt;child classes of student should be forced to implement getLetterGrade()&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;u&gt;Solution&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;declare Student an abstract class&lt;/li&gt;&lt;ul&gt;&lt;li&gt;can't instantiate an object of type student&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;declare getLetterGrade() an abstract method within abstract class student&lt;/li&gt;&lt;li&gt;children must override getLetterGrade() or they will be abstract classes themselves&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public abstract class Student&lt;br /&gt;{&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;public abstract String getLetterGrade();&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-5297761037694962741?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/5297761037694962741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=5297761037694962741' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5297761037694962741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/5297761037694962741'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-11_31.html' title='Lecture 11'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3097550281930527110</id><published>2007-01-30T17:34:00.000-05:00</published><updated>2007-01-30T17:37:44.691-05:00</updated><title type='text'>Lab Test 1 Finished Impressions</title><content type='html'>today I finished the LabTest&lt;br /&gt;i found it difficult, it was basically like starting a half finished lab from previous weeks.&lt;br /&gt;key things on it were&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;JavaDoc&lt;/li&gt;&lt;ul&gt;&lt;li&gt;know @param and @return&lt;/li&gt;&lt;li&gt;know /**, */ are the opening and closing parenthesis&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Copy Constructors&lt;/li&gt;&lt;ul&gt;&lt;li&gt;know how to deep copy&lt;/li&gt;&lt;li&gt;know what kinds of classes need to be copy constructed&lt;/li&gt;&lt;ul&gt;&lt;li&gt;only mutable classes need a copy constructor&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;Understand how to make methods from scratch, such as equals() and toString()&lt;/li&gt;&lt;li&gt;aside from that , just study what goes in a constructor&lt;/li&gt;&lt;ul&gt;&lt;li&gt;and how to test it.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3097550281930527110?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3097550281930527110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3097550281930527110' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3097550281930527110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3097550281930527110'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lab-test-1-finished-impressions.html' title='Lab Test 1 Finished Impressions'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4800323723405002792</id><published>2007-01-29T12:46:00.000-05:00</published><updated>2007-01-29T12:52:49.048-05:00</updated><title type='text'>LabTest 1 Impressions</title><content type='html'>Here you can post how you felt the test went, give pointers to those who haven't taken it and so on.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;We asked Andrew about test specifications&lt;/li&gt;&lt;ul&gt;&lt;li&gt;he said 'In the book, so far we have done chapters 3 and 9, and a little bit of chapter 13.'&lt;/li&gt;&lt;li&gt;he also said the best way to study for it is lecture notes, as there is material he skipped that we shouldn't have to be tested on&lt;/li&gt;&lt;li&gt;he said the Lab Tests will commonly be&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;editing sample code that doesn't work&lt;/li&gt;&lt;li&gt;make a class w/ a given API&lt;/li&gt;&lt;li&gt;make a class of your own that meets specs (similar to what we've done in lab1 / lab2&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;Off topic from the test...&lt;br /&gt;&lt;br /&gt;how do you guys feel about the lab TA's?&lt;br /&gt;I want Maan back, I can never really get much coherent help.. but if you guys know a good TA i should be talking to .. post their name on here for me.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Andrew posted this on his site about test:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://cse1030w0607.blogspot.com/2007/01/lab-test-reminder.html"&gt;Click&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-4800323723405002792?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/4800323723405002792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=4800323723405002792' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4800323723405002792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/4800323723405002792'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/labtest-1-impressions.html' title='LabTest 1 Impressions'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8327664333092563238</id><published>2007-01-29T12:32:00.000-05:00</published><updated>2007-01-31T12:57:44.914-05:00</updated><title type='text'>Lecture 11</title><content type='html'>&lt;u&gt;Inheritance&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;say we are implementing a database of students in a course&lt;/li&gt;&lt;ul&gt;&lt;li&gt;course is open to both undergraduate and graduate students&lt;/li&gt;&lt;li&gt;obviously, the student records will be largely the same&lt;/li&gt;&lt;/ul&gt;&lt;li style="font-weight: bold;"&gt;All students have&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Name&lt;/li&gt;&lt;li&gt;Student Number&lt;/li&gt;&lt;li&gt;Raw Percentage Score&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;calculation of the letter grade is different between these students&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;Undergrad&lt;/li&gt;&lt;ul&gt;&lt;li&gt;A 80-100%&lt;/li&gt;&lt;li&gt;B 70-80%&lt;/li&gt;&lt;li&gt;C  60-70%&lt;/li&gt;&lt;li&gt;D 50-60%&lt;/li&gt;&lt;li&gt;F &lt;50%&lt;/li&gt;&lt;/ul&gt;&lt;li style="font-weight: bold;"&gt;Graduate Student&lt;/li&gt;&lt;ul&gt;&lt;li&gt;A 80-100%&lt;/li&gt;&lt;li&gt;B 70-80%&lt;/li&gt;&lt;li&gt; F &lt;70%&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;inefficient to implement two separate classes when they overlap so much&lt;/li&gt;&lt;li&gt;intuitively, both an undergrad and grad are types of students with certain features in common. it would be nice if student class could handle common functions and that this class could be extended&lt;/li&gt;&lt;li&gt;Java allows us to extend this way using inheritance&lt;/li&gt;&lt;ul&gt;&lt;li&gt;use the &lt;span style="font-weight: bold;"&gt;'extends'&lt;/span&gt; keyword to declare child classes&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;public class Student&lt;br /&gt;{&lt;br /&gt;//parent class&lt;br /&gt;//takes care of common features&lt;br /&gt;//student name / number / raw score&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;____________________________________&lt;br /&gt;&lt;br /&gt;public class underGradStudent extends Student&lt;br /&gt;{&lt;br /&gt;//undergrad letter grade calculation&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;____________________________________&lt;br /&gt;&lt;br /&gt;public class gradStudent extends Student&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;//grad letter grade calculation&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;_____________________________________&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;u&gt;Inheritance and Constructors&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;if you provide no constructor in a child class that will lead the compiler to call the default constructor of the parent and will generate an error if that doesn't exist.&lt;/li&gt;&lt;li&gt;provide a constructor&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;presumably you went to call the constructor of the parent class&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;use the keyword 'super' (works like keyword 'this')&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Access Specifiers&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;private members are hidden from children&lt;/li&gt;&lt;li&gt;this is sometimes valuable to have internal hidden variables that can't be manipulated outside your class&lt;/li&gt;&lt;li&gt;protected objects are visible to children but not the public&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Package and Access Restrictions&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;four valid access specifiers&lt;/li&gt;&lt;ul&gt;&lt;li&gt;private&lt;/li&gt;&lt;ul&gt;&lt;li&gt;most restricted&lt;/li&gt;&lt;li&gt;class file only&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;nothing&lt;/li&gt;&lt;ul&gt;&lt;li&gt;access within package&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;protected&lt;/li&gt;&lt;ul&gt;&lt;li&gt;access within package and children&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;public&lt;/li&gt;&lt;ul&gt;&lt;li&gt;accessible everywhere&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;ignore packages&lt;/li&gt;&lt;ul&gt;&lt;li&gt;and java puts all files in the same package&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;package&lt;/li&gt;&lt;ul&gt;&lt;li&gt;package level access throughout the code&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;Creating and Using Package&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;u&gt;Create a package&lt;/u&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;think of a name for package&lt;/li&gt;&lt;ol&gt;&lt;li&gt;all lower case letters&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;create a directory with that name&lt;/li&gt;&lt;ol&gt;&lt;li&gt;move all files to that directory&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;in all files in student write the following statement as the first line&lt;/li&gt;&lt;ol style="font-family: courier new;"&gt;&lt;li&gt;package student;&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;using the package&lt;/li&gt;&lt;ol&gt;&lt;li&gt;at the top you write the following&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;import student.*;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8327664333092563238?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8327664333092563238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8327664333092563238' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8327664333092563238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8327664333092563238'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-11.html' title='Lecture 11'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6544703047528157931</id><published>2007-01-27T12:19:00.000-05:00</published><updated>2007-01-29T12:32:23.994-05:00</updated><title type='text'>Lecture 10</title><content type='html'>&lt;ul&gt;&lt;li&gt;Delegation within the class definition&lt;/li&gt;&lt;ul&gt;&lt;li&gt;code is sometimes used over and over within the methods of a class&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;constructors =&gt;implement the constructor that takes all possible arguements and call that constructor from the other constructors.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;why do this?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;saves you time&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;making changes is much easier, and less error prore(eg. you might miss a change.)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Constructor Fields(final keyword)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;best practice to use a variable to store any constants used by your program&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;want these values to be protected from change&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;public final int CONSTANTS = s;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;constant is initially given the value s&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;no entity in the program is allowed to alter constant&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;final entities must be initialized on the same line that they are declared&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;stylistically, final variables are always written in all caps.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;why use constants?&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Example.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;private int x&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;private final int MAX = 500;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;if (x &gt; MAX - x ) { }&lt;/span&gt;&lt;ul&gt;&lt;ul&gt;&lt;li&gt;-there are other uses of final&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;   method class&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;inheritance&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;   variable &lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;constant&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;The constant feature only works with primitives&lt;/li&gt;&lt;li&gt;if you declare an object final, that object does not magically become immutable&lt;/li&gt;&lt;li&gt;Preconditions and postconditions as the system programmer, you have a contractual relationship with the application programmer.&lt;/li&gt;&lt;/ul&gt;Precondition:&lt;ul&gt;&lt;li&gt;AP calls your methods satisfying conditions which you specify&lt;/li&gt;&lt;li style="font-family: courier new;"&gt;eg. amount &gt;= 0 indeposit(), withdrawal&lt;/li&gt;&lt;li&gt;Postcondition:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;In return, you agree that the method output satisfies given conditions&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Example: getbalance() returns the correct balance&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Preconditions dont need to be checked&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;postcondition should be checked during debugging&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;assert checking to ensure postconditions be satisfied&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;pre and postconditions must be specified in javadoc&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6544703047528157931?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6544703047528157931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6544703047528157931' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6544703047528157931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6544703047528157931'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-10.html' title='Lecture 10'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3498756211696291225</id><published>2007-01-24T12:23:00.000-05:00</published><updated>2007-01-24T12:37:28.711-05:00</updated><title type='text'>Lecture 9</title><content type='html'>&lt;u&gt;Special Functions&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;already we have seen clone()&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this is a special method that is possessed by all objects&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;we will talk about two more in this lecture&lt;/li&gt;&lt;ul&gt;&lt;li&gt;toString()&lt;/li&gt;&lt;li&gt;equals()&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;ToString()&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;returns an object of type String&lt;br /&gt;&lt;/li&gt;&lt;li&gt;'cast' your object object to a string type&lt;/li&gt;&lt;li&gt;creates a string output of your objects current state&lt;/li&gt;&lt;ul&gt;&lt;li&gt;contents of all private instance fields&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;very useful for debugging&lt;/li&gt;&lt;li&gt;the compiler uses toString() whenever it needs to cast your object to a String&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;MyObject x = new MyObject();&lt;br /&gt;System.out.println(x);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul style="font-family: georgia;"&gt;&lt;li&gt;println takes a String argument&lt;/li&gt;&lt;li&gt;this is equivalent to saying:&lt;/li&gt;&lt;li&gt;System.out.println(x.toString());&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;In a toString method you should do the following&lt;/li&gt;&lt;ul&gt;&lt;li&gt;include the name of the class&lt;/li&gt;&lt;li&gt;include all the private fields&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;if MyObject contains only a private int a&lt;/li&gt;&lt;ul&gt;&lt;li&gt;toString() output should be&lt;/li&gt;&lt;ul&gt;&lt;li&gt;MyObject[a=0]&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Equals()&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;returns a boolean&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;true or false&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;checks to see whether two objects are equal&lt;/li&gt;&lt;li&gt;returns true if they are equal, false if they are not&lt;/li&gt;&lt;/ul&gt;The default form of this method is&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Public boolean equals(Object, OtherObject)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;we must use the most general form of the default equals() in order to capture all objects&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;Public Class MyObject{&lt;br /&gt;&lt;br /&gt;private int x;&lt;br /&gt;public boolean equals(Object, OtherObject){&lt;br /&gt;MyObject other = (MyObject)OtherObject;&lt;br /&gt;return (this.x == other.x);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;if x and y are objects and not primitives then&lt;/li&gt;&lt;ul&gt;&lt;li&gt;x==y if x and y point to the same object&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Delegation within the class&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Example: code used by many methods in the same class&lt;/li&gt;&lt;li&gt;Example: Constructors&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3498756211696291225?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3498756211696291225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3498756211696291225' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3498756211696291225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3498756211696291225'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-9.html' title='Lecture 9'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-6558723684706029721</id><published>2007-01-22T12:50:00.000-05:00</published><updated>2007-01-22T12:51:20.950-05:00</updated><title type='text'>Lab 2</title><content type='html'>Please Post your ideas for Lab 2 here! I haven't started yet, my labs are on tuesday!&lt;br /&gt;&lt;br /&gt;For Lab Instructions: &lt;a href="http://www.cse.yorku.ca/course_archive/2006-07/W/1030/labs/lab2/"&gt;Click&lt;/a&gt; &lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-6558723684706029721?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/6558723684706029721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=6558723684706029721' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6558723684706029721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/6558723684706029721'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lab-2.html' title='Lab 2'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-3599258356946371261</id><published>2007-01-22T12:43:00.000-05:00</published><updated>2007-01-22T12:48:12.109-05:00</updated><title type='text'>Lecture 8</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;Scope of Variables&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;ul&gt; &lt;li&gt; &lt;span style="text-decoration: underline;"&gt;&lt;span style="text-decoration: underline;"&gt;how far are the declared variables visible in code?&lt;/span&gt;&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span style="text-decoration: underline;"&gt;&lt;span style="text-decoration: underline;"&gt;when is it safe to refuse variable names?&lt;/span&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ol&gt; &lt;li&gt; Local variables within a method &lt;/li&gt; &lt;ol&gt; &lt;li&gt; always applies to the method parameters &lt;/li&gt; &lt;li&gt; the scope of local variables is the set of {} that contains the definition &lt;/li&gt; &lt;li&gt; this is usually, but not always, the braces {} surrounding the entire method &lt;/li&gt; &lt;li&gt; not allowed to have two variables of the same name within the same set of braces{} &lt;/li&gt; &lt;/ol&gt; &lt;/ol&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;Example&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;public void method(){&lt;/span&gt;  &lt;span style="font-family:Courier New;"&gt;int x=o;&lt;/span&gt;  &lt;span style="font-family:Courier New;"&gt;int x=5; // illegal&lt;/span&gt;  &lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;Example 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;public void method(){&lt;br /&gt;&lt;span style="font-style: italic;"&gt;x=0 //illegal&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if (y==5)&lt;br /&gt;{ int x = 0;&lt;br /&gt; x=x+y;&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;int x = 5;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;ul&gt; &lt;li&gt; &lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:Verdana;"&gt;x is only accessible through the scope of {} between if and else&lt;/span&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt; &lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:Verdana;"&gt;putting x = 0 at the top is illegal because it is outside the desired scope&lt;/span&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt;&lt;br /&gt; 2. &lt;u&gt;Local variables vs. Instance Fields&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;public class BankAccount{&lt;br /&gt;Private double &lt;span style="font-style: italic;"&gt;balance&lt;/span&gt;;&lt;br /&gt;public void method ()&lt;br /&gt;{&lt;br /&gt;double balance; //legal&lt;br /&gt;balance = 0; // legal - this is legal because   local variables take precedence&lt;br /&gt;&lt;br /&gt;this.balance = 0; // instance field relates to &lt;span style="font-style: italic;"&gt;balance&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;3. &lt;u&gt;Multiple Objects&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;ul&gt; &lt;li&gt; methods of an object can see private fields of any object of that class &lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;private double balance&lt;br /&gt;&lt;br /&gt;public void method(BankAccount x){&lt;br /&gt;balance = 0; //current object&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;x.balance = 0&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;// other &lt;span style="font-style: italic;"&gt;object&lt;br /&gt;&lt;br /&gt;// if user typed x.method(y) then x would relate to &lt;/span&gt;balance = 0 and y would relate to &lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;balance = 0&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: underline;"&gt;Clone, shallow copies, deep copies&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;ul&gt; &lt;li&gt; &lt;span style="font-family:Courier New;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;implement &lt;span style="text-decoration: underline;"&gt;copy constructors&lt;/span&gt; to perform &lt;span style="text-decoration: underline;"&gt;defensive copies&lt;/span&gt; which avoids &lt;span style="text-decoration: underline;"&gt;privacy leaks&lt;/span&gt;&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span style="font-family:Courier New;"&gt;you may be tempted to use the method clone() as an easy copy constructor.&lt;/span&gt;  &lt;/li&gt;  &lt;li&gt;  &lt;span style="font-family:Courier New;"&gt;the only time to use clone() is if no copy constructor is defined.&lt;/span&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-family:Courier New;"&gt;example&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;MOWC a,b;&lt;br /&gt;a = new MOWN();&lt;br /&gt;b=a.clone(); // creates a shallow copy of a and store it in b&lt;br /&gt;&lt;br /&gt;// this is similar to but not identical to using the copy constructor&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;what does clone do?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;ul&gt;  &lt;li&gt;  creates a bitwise copy of the object &lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;{ int a,b;&lt;br /&gt;private myobject c;}&lt;br /&gt;// my object is mutable}&lt;br /&gt;&lt;br /&gt;//console&lt;br /&gt;x = new MOWC():&lt;br /&gt;//this example would give a reference to myobject c even if copied it will reference the same object instead of a new&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;ul&gt;  &lt;li&gt;  two references &lt;/li&gt;  &lt;li&gt;  changes y to show up in x &lt;/li&gt;  &lt;li&gt;  privacy leak &lt;/li&gt;  &lt;li&gt;  this is a shallow copy &lt;/li&gt;  &lt;li&gt;  clone() implements a &lt;span style="text-decoration: underline;"&gt;shallow&lt;/span&gt;  copy, which does not respect the semantics of the object it copies &lt;/li&gt;  &lt;li&gt;  shallow copies can lead to a privacy leak &lt;/li&gt;  &lt;li&gt;  &lt;span style="text-decoration: underline;"&gt;Deep Copy&lt;/span&gt;  &lt;/li&gt;  &lt;ul&gt;  &lt;li&gt;  &lt;span style="text-decoration: underline;"&gt;implements a copy constructor&lt;/span&gt;  &lt;/li&gt;  &lt;/ul&gt; &lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;public class MOWC(MOWC in){&lt;br /&gt;a = in.a;&lt;br /&gt;b=in.b;&lt;br /&gt;c= new myobject(in.c);&lt;br /&gt;}&lt;br /&gt;//this is the correct way to deep copy&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;ul&gt;  &lt;li&gt;  shallow copy is safe if your object contains&lt;br /&gt;&lt;/li&gt;  &lt;ul&gt;  &lt;li&gt;  primitives &lt;/li&gt;  &lt;li&gt;  immutable classes &lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt;  deep copy is mandatory if object contains mutable classes &lt;/li&gt;  &lt;li&gt;  &lt;span style="text-decoration: underline;"&gt;From Now On&lt;/span&gt;  &lt;/li&gt;  &lt;ul&gt;  &lt;li&gt;  properly implement a copy constructor for all mutable classes that you design &lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt;  &lt;span style="text-decoration: underline;"&gt;Only&lt;/span&gt;  &lt;/li&gt;  &lt;ul&gt;  &lt;li&gt;  use clone() if no copy constructor exists&lt;br /&gt;&lt;/li&gt;  &lt;/ul&gt; &lt;/ul&gt; &lt;span style="font-family:Courier New;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-3599258356946371261?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/3599258356946371261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=3599258356946371261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3599258356946371261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/3599258356946371261'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-8.html' title='Lecture 8'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-1639822440954906505</id><published>2007-01-19T12:14:00.000-05:00</published><updated>2007-01-19T12:40:58.941-05:00</updated><title type='text'>Lecture 7</title><content type='html'>&lt;div&gt;&lt;u&gt;Javadoc&lt;/u&gt;&lt;/div&gt; &lt;ul&gt;&lt;li&gt;an automated tool for documentation and generation of your java code&lt;/li&gt;&lt;li&gt;operates through the comments in your java code&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;u&gt;Remember: Java Comments&lt;/u&gt;&lt;/p&gt; &lt;p&gt;//... -&gt; is a single line comment&lt;/p&gt; &lt;p&gt;/* ... */ -&gt; is a multiline comment&lt;/p&gt; &lt;p&gt;/** ... */ -&gt; format used for &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Javadoc&lt;/span&gt; documentation&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-style: italic;"&gt;Note: for this documentation '...' refers to details you filled in.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;document every public entity in your code&lt;/li&gt;&lt;li&gt;place the /** ... */ comments (&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Javadoc&lt;/span&gt; comments) immediately prior to each  &lt;strong&gt;public&lt;/strong&gt; entry&lt;/li&gt;&lt;li&gt;&lt;u&gt;Entries that should have &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Javadoc&lt;/span&gt; comments:&lt;/u&gt;&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;the class itself&lt;/li&gt;&lt;li&gt;the constructors (public)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;the methods (public)&lt;/li&gt;&lt;li&gt;any public fields&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;any non-&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;Javadoc&lt;/span&gt; comments will be ignored by &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;Javadoc&lt;/span&gt;. So you can still comment your code as necessary&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;/** this class contains a &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;BankAccount&lt;/span&gt; balance and provides methods for manipulating that balance */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: courier new;font-family:courier new;" &gt;public&lt;/span&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt; class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;BankAccount&lt;/span&gt; {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;/** this is the default constructor which sets the balance to zero */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: courier new;font-family:courier new;" &gt;public&lt;/span&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt; &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;BankAccount&lt;/span&gt;(){balance=0;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;//info goes here&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: courier new;font-family:courier new;" &gt;private&lt;/span&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt; double balance; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: courier new;font-family:courier new;" &gt;//no &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;Javadoc&lt;/span&gt; comments here, &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_9"&gt;because&lt;/span&gt; this is not part of the public&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: courier new;font-family:courier new;" &gt;//even if &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;Javadoc&lt;/span&gt; sees &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;Javadoc&lt;/span&gt; comments here it will avoid when rendering itself&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style="font-family: georgia;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;Javadoc&lt;/span&gt; has special keywords used within a &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;Javadoc&lt;/span&gt; comment to document parameters and return values&lt;/li&gt;&lt;ul&gt;&lt;li style="font-family: georgia;"&gt;@&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;param&lt;/span&gt; - &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_15"&gt;parameters&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: georgia;"&gt;@return - return values&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;/** Add a deposit to the current balance &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;@&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;param&lt;/span&gt; amount amount of the deposit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;public void deposit(double amount){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;balance = balance + amount&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family: courier new;font-family:courier new;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;u&gt;Example 2&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;/** returns the current balance &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;@return The value of the current balance&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;*/&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;public double &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;getbalance&lt;/span&gt;(){return balance;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//double is a 'non void' return value&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Console:&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;javadoc&lt;/span&gt; &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;BankAccount&lt;/span&gt;.java&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;if you have more than one java file in the folder you wish to create a &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;Javadoc&lt;/span&gt; for&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;$&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;javadoc&lt;/span&gt; *.java&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;this creates many different files that will be included in the &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;Javadoc&lt;/span&gt; file. to access the file in a &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;webbrowser&lt;/span&gt; open index.html&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;Javadoc&lt;/span&gt; Practices&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;Javadoc&lt;/span&gt; documents the public interface of your code (everything w/ the public tag)&lt;/li&gt;&lt;li&gt;it's up to you to provide descriptions. Be as detailed as reasonable&lt;/li&gt;&lt;li&gt;good practice to produce &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;Javadoc&lt;/span&gt; at the same time as the public interface&lt;/li&gt;&lt;li&gt;Always Document your Code!!!&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-1639822440954906505?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/1639822440954906505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=1639822440954906505' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1639822440954906505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1639822440954906505'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-7.html' title='Lecture 7'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-8047475519503114614</id><published>2007-01-17T15:48:00.000-05:00</published><updated>2007-01-17T15:53:28.941-05:00</updated><title type='text'>LAB 1 Notes/Code PLEASE POST COMMENTS!!</title><content type='html'>Disclaimer: haven't programmed Java since last semester, feels like i lost quite a lot of skill, anyways i conjured up this much. it basically does everything in the details that Andrew asked for, HOWEVER , i am completely useless when incorporating a monthly compiler. I'm guessing i'll have to use the Calendar class... any ideas? please post code / remarks on this page. I think the best way to tackle labs will be using this blog.&lt;br /&gt;&lt;br /&gt;anyways here's what i got so far, it compiles so you can see what i'm up to usin the mybank.java that Andrew provided.. quicklink to the assignment: &lt;a href="http://www.cse.yorku.ca/course_archive/2006-07/W/1030/labs/lab1.pdf"&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;Click&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;thanks,&lt;br /&gt;Jake&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class BankAccount {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    // Constructor&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public BankAccount() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        balance = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public BankAccount(double balance, double interest) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    {    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.balance = balance;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.interest = interest;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.monthfee = 10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.deposittotal = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.withdrawtotal = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.overbalance = 5000;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.overdeposit = 200;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    // Methods&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void changfee(double monthfee) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.monthfee = monthfee;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void deposit(double amount) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        balance = balance + amount;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        deposittotal = deposittotal + amount;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void withdraw(double amount) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        balance = balance - amount;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        withdrawtotal = withdrawtotal + amount;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public double getbalance() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        return balance;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void changeob(double overbalance) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.overbalance = overbalance;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void changedep(double overdeposit) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        this.overdeposit = overdeposit;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void changeinterest(double interest) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    this.interest = interest;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public void compilebalance() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    //class that compiles all fees and interest&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        balance = balance + (balance * interest);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        if (balance &gt; overbalance)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        monthfee = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        if ((deposittotal - withdrawtotal) &gt; overdeposit) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        monthfee = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        balance = balance - monthfee;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    // Instance Fields&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private double balance;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private double interest;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private double monthfee;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public double deposittotal;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    public double withdrawtotal;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private double overbalance;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private double overdeposit;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}    &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-8047475519503114614?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/8047475519503114614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=8047475519503114614' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8047475519503114614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/8047475519503114614'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lab-1-notescode-please-post-comments.html' title='LAB 1 Notes/Code PLEASE POST COMMENTS!!'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-1498766687641440485</id><published>2007-01-17T15:12:00.000-05:00</published><updated>2007-01-17T15:29:46.658-05:00</updated><title type='text'>Lecture 6</title><content type='html'>&lt;u&gt;Objects vs. Primitives&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;4 integer types - byte, short, long, int&lt;/li&gt;&lt;li&gt;2 floating point types  - float, double&lt;/li&gt;&lt;li&gt;1 Boolean&lt;/li&gt;&lt;li&gt;1 char&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;remember if A and B are objects and we write a=b&lt;/li&gt;&lt;li&gt;then a is A is a reference to B, A is NOT a copy of B&lt;br /&gt;&lt;/li&gt;&lt;li&gt;the exact opposite occurs when A,B are primitives&lt;/li&gt;&lt;li&gt;reference passing can happen in 3 ways:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;a=b&lt;/li&gt;&lt;li&gt;parameter passing&lt;/li&gt;&lt;li&gt;return value passing&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;privacy violations can occur unless you are careful&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Defensive Copying&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Defensive copying is used to force all interactions w/ private fields to go through the public interface (example: through the class methods)&lt;/li&gt;&lt;li&gt;Defensive copies of mutable objects are always performed when an object is into or out of a class (Shield the reference from the outside world)&lt;/li&gt;&lt;li&gt;Constructors (in) - as parameters&lt;/li&gt;&lt;li&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Accessors&lt;/span&gt;(out) - as return values&lt;/li&gt;&lt;li&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Mutators&lt;/span&gt; (in) - as parameters&lt;/li&gt;&lt;/ul&gt;Example&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;myclass&lt;/span&gt;(x)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myclass&lt;/span&gt; &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;accessor&lt;/span&gt;(){&lt;br /&gt;return x; //BAD!!&lt;br /&gt;//this is bad &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;becuase&lt;/span&gt; it passes the reference outside the class&lt;br /&gt;&lt;br /&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;myclass&lt;/span&gt; copy_of_x = new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;myclass&lt;/span&gt;(x);&lt;br /&gt;return copy_of_x; //OK!!&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;Example 2&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;myclass&lt;/span&gt;(x)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public void &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;mutator&lt;/span&gt;(&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;myclass&lt;/span&gt; x_in){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;x=x_in; //BAD!!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//because whoever called the &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;mutator&lt;/span&gt; pertains a reference to x_in, which is a direct reference of x.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;myclass&lt;/span&gt; copy_of_x_in = new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;myclass&lt;/span&gt;(x_in)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;x=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;copy_of_x_in &lt;span style="font-style: italic;font-family:arial;" &gt;// GOOD!!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;u&gt;Immutable Classes&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;an immutable class is a class whose private fields cannot be changed after construction&lt;/li&gt;&lt;li&gt;a mutable class is the opposite and can change after construction&lt;/li&gt;&lt;li&gt;an immutable class has the following properties&lt;/li&gt;&lt;ul&gt;&lt;li&gt;all instance fields are private&lt;/li&gt;&lt;li&gt;no &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;mutators&lt;/span&gt;&lt;/li&gt;&lt;li&gt;and either&lt;/li&gt;&lt;ul&gt;&lt;li&gt;all private/instance fields are primitives&lt;br /&gt;&lt;/li&gt;&lt;li&gt;or themselves a primitive&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;or&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;defensive copies are always made of any mutable classes&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;if a class is truly immutable then defensive copies do not need to be made of it&lt;/li&gt;&lt;ul&gt;&lt;li&gt;therefore it's perfectly OK to share references of mutable classes&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;this saves memory&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Immutable classes do not require copy constructors&lt;/li&gt;&lt;li&gt;mutable classes MUST have copy constructors (for defensive copying)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-1498766687641440485?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/1498766687641440485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=1498766687641440485' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1498766687641440485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1498766687641440485'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-6.html' title='Lecture 6'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-1893582125423655943</id><published>2007-01-17T14:55:00.000-05:00</published><updated>2007-01-17T15:11:49.991-05:00</updated><title type='text'>Lecture 5</title><content type='html'>Static Fields&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;an instance field is a field contained within each and every object of a particular class&lt;/li&gt;&lt;li&gt;a static field is a field for the entire class&lt;/li&gt;&lt;ul&gt;&lt;li&gt;one for the entire class&lt;/li&gt;&lt;li&gt;can access a static field w/o instantiating any objects&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;Example 1&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;can be used to store constants in a utility&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: courier new;"&gt;private static double pi = 3.14&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public static double &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;getpi&lt;/span&gt;(){return pi;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Example 2&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Can use a static field to keep track of the number of instances of a class.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Caution about static: do not over use it&lt;br /&gt;&lt;ul&gt;&lt;li&gt;if you make everything static then objects and classes become meaningless&lt;/li&gt;&lt;li&gt;is will no longer be object oriented if static classes are only involved&lt;/li&gt;&lt;/ul&gt;Copy Constructor&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a special kind of constructor that is used for copying objects&lt;/li&gt;&lt;li&gt;how do we create a new object that is a copy of an existing object?&lt;/li&gt;&lt;/ul&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;myobject&lt;/span&gt; x,y;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;y=new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;myobject&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;y=x; // this is bad!!!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;this does not create a copy, it makes y another name for x. if i make changes to y, those changes also occur to x.&lt;/li&gt;&lt;li&gt;this also works both ways&lt;/li&gt;&lt;li&gt;Copy Constructor is the proper strategy&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: courier new;"&gt;public class &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myobject&lt;/span&gt; {//two private fields: a,b&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;public &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myobject&lt;/span&gt; (&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myobject&lt;/span&gt; Source) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;//'Source' is the variable name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;//copy constructor&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;a = source.a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;b = source.b&lt;br /&gt;&lt;br /&gt;x = new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;myobject&lt;/span&gt;();&lt;br /&gt;y = new &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;myobject&lt;/span&gt;(x);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;this raises important points about Java objects:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;the variable name is only a reference to the object. it does NOT contain the object itself&lt;/li&gt;&lt;li&gt;that's why  y=x does not COPY&lt;/li&gt;&lt;ul&gt;&lt;li&gt;it makes y a reference to x&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;this is true for all objects in Java.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Exception to this rule&lt;/li&gt;&lt;ul&gt;&lt;li&gt;primitive types are not objects&lt;/li&gt;&lt;ul&gt;&lt;li&gt;byte (8 bit)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;short (16 bit)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;int (32 bit)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;long(64 bit)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;float(real number - 32 bit)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;double(real number - 64 bit)&lt;/li&gt;&lt;li&gt;Boolean(true/false)&lt;/li&gt;&lt;li&gt;char(Unicode character)&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;int x,y&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;x=5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;y=x //this is &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_8"&gt;OK&lt;/span&gt;, y will make it's own primitive w/ value 5 while x will also be separate from y&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Mutable Classes&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;mutable classes have private fields that can change after instantiation&lt;/li&gt;&lt;/ul&gt;Immutable Classes&lt;br /&gt;&lt;ul&gt;&lt;li&gt;not allowed to change after construction&lt;/li&gt;&lt;li&gt;the reference is passed not only when = occurs, but also whenever objects are passed around&lt;/li&gt;&lt;ul&gt;&lt;li&gt;method parameters&lt;/li&gt;&lt;li&gt;return values&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;privacy violations occur unless care is taken to properly copy objects &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-1893582125423655943?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/1893582125423655943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=1893582125423655943' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1893582125423655943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/1893582125423655943'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-5.html' title='Lecture 5'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-2397679334163382490</id><published>2007-01-17T14:38:00.000-05:00</published><updated>2007-01-17T15:33:24.656-05:00</updated><title type='text'>Lecture 4</title><content type='html'>&lt;u&gt;Employee Database&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;say you are implementing an employee database&lt;/li&gt;&lt;li&gt;Employee' will be an object&lt;/li&gt;&lt;li&gt;Employees start out w/ an employee number which is given but never changes&lt;/li&gt;&lt;li&gt;default salary is $40,000 which can change or start different&lt;/li&gt;&lt;li&gt;employees have names which are initially given but CAN change&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Need to be able to read:&lt;/li&gt;&lt;/ul&gt;&lt;ul style="margin-left: 40px;"&gt;&lt;li&gt;Name&lt;/li&gt;&lt;li&gt;Employee Number&lt;/li&gt;&lt;li&gt;Annual Salary&lt;/li&gt;&lt;li&gt;Monthly Salary&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;these are the 'accessors' for the program.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class Employee {&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//constructors&lt;/span&gt;&lt;br /&gt;public Employee (String name, int enum, double salary)&lt;br /&gt;public Employee (String name, int enum)&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//methods: accessors&lt;/span&gt;&lt;br /&gt;public String GetName()&lt;br /&gt;public int GetEmNum()&lt;br /&gt;public double GetAnnSalary()&lt;br /&gt;public double GetMonSalary()&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//methods: mutators&lt;/span&gt;&lt;br /&gt;public void SetName(String Name)&lt;br /&gt;public void SetSalary(double salary)&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//fields&lt;/span&gt;&lt;br /&gt;private String EmployeeName;&lt;br /&gt;private int EmployeeNumber;&lt;br /&gt;private double EmployeeSalary;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://www.cse.yorku.ca/course_archive/2006-07/W/1030/week1/Employee/"&gt;&lt;span style="color: rgb(51, 102, 255);font-family:courier new;" &gt;&lt;span style="font-family:arial;"&gt;Click&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;after writing this on the board Andrew carried on w/ code he prepared before class&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;u&gt;Utility Classes And The 'Static' Keyword&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;a utility class is a special class w/ no fields that only provides methods that are useful to other  objects.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;example: java.lang.math&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;u&gt;Why Have Utilities?&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;to organize useful methods in a matter similar to objects&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;use methods w/o involking storage&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;b&gt;example:&lt;/b&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;double x;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;x.sqrt();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;the keyword 'static' is used to refer to methods that can be used independantly of objects&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;class myClass {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public static void mymethod(){}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;myClass mc = new myClass();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;//legal to say &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;mc.mymethod();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;//also legal to say &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;myclass.mymethod(); //better practice&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;//legal to use even if no objects of type myClass exist&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;ex&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;ample 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public class myutil{&lt;br /&gt;&lt;br /&gt; public static int addint(int a, int b){&lt;br /&gt;&lt;br /&gt; return a+b;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;c= myutil.addint(3,4;&lt;br /&gt;&lt;br /&gt;system.out.println(c);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;//console&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;return: 7&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;Can prevent the compiler from crashing an object relating to a  utility class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;use a private constructor&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;private myutil(){}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;// prevents someone trying to make a 'myutil' object&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;now no outside class has the right to execute the constructor, so an object type util cannot be created. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9107963745788914426-2397679334163382490?l=jacobdevos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jacobdevos.blogspot.com/feeds/2397679334163382490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9107963745788914426&amp;postID=2397679334163382490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2397679334163382490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9107963745788914426/posts/default/2397679334163382490'/><link rel='alternate' type='text/html' href='http://jacobdevos.blogspot.com/2007/01/lecture-4.html' title='Lecture 4'/><author><name>Jake</name><uri>http://www.blogger.com/profile/03113555816517589981</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9107963745788914426.post-4779347854753053468</id><published>2007-01-17T13:09:00.000-05:00</published><updated>2007-01-17T15:37:34.820-05:00</updated><title type='text'>Lecture 3</title><content type='html'>Continuing Bank Account Example&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;include the &lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;BankAccount&lt;/span&gt; object in a real program in order to use it.&lt;/li&gt;&lt;li&gt;a valid java program must contain a class w/ the special method 'main'&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;ex.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;Public class &lt;/span&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;mybank&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;public static void main (string &lt;/span&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;args&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;[]) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;BankAccount&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;mysavings&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; = new &lt;/span&gt;&lt;s
