onsdag 13 juni 2012

Skapa jar-fil i eclipse

Föreläsning 26 handlade om hur du skapar en jar-fil i eclipse och om "standardjava", dvs hur man kodar om man inte har tillgång till acm-biblioteket. Han gick bland annat igenom main, vilket gav mig en härlig känsla av att det här kan jag ju redan.

måndag 11 juni 2012

Thread

Föreläsning 25.

Thread - att göra många saker, som du upplever att du gör, samtidigt. Ex kollar mailen, surfar, kollar play.
Multithreading pratade han också om. Hittade dock den här sidan som tar upp det mer ingående.

Struktur

Föreläsning 24.

Denna gång går Mehran igenom ett programs struktur, hur du ska tänka när du bygger ditt program.

Principles:
nouns (substantiv) - classes
verbs - methods (associated with your classes)
unique identifier ex. Stanford Uni IDnr, ISBN nr, Artist + album + song

Design
collection of objects

Ex a musicstore called FlyTunes
add Songs
add Albums

class Song:   name - String
                    band - String
                    price - Double
Think about: What's gonna stay static and what's gonna change?

fredag 8 juni 2012

Searching and sorting

Lecture 23.

Searching: Linear and Binary
Finding a particular element in an array or some other kind of sequence. The element is called a key.

Linear Search
- timeconsuming

private int linearSearch (int key, int[] array){
   for (int i = 0; i < array.length; i++) {
      if (key == array[i]) return i;
   }
   return -1;
}

Binary search
Ask if the nr is higher/lower than the middle nr. Then ask again and again...
The idea of the binary search is the fact that area code array is an ascending order makes it possible to find a particular value much more efficiently. The key insight is that you get more information by starting at the middle element than you do by starting at the beginning.

private int binarySearch(int key){
   int kh = 0;
   int lh = display.length() -1;
      while ( lh <= rh){
         int mid = (lh+rh) / 2;
      if (key == disp.get(mid)) return mid;
      if (key < disp.get(mid)){
         rh = mid -1; //to move from the midpoint
}
   else{
      lh = mid +1;
}

Sorting
Selection sort and Radix sort algorithm
}
return -1;
}


torsdag 7 juni 2012

Blogg

En blogg för nybörjare med vad det verkar, bra och enkla förklaringar och en hel del kod. Me like! A Beginning Programmer's guide to Java.

Using Graphics

I am trying to find some useful code to understand Graphics better. This one and two pages was quite useful.


tisdag 5 juni 2012

Components and containers

Lecture 22.

Mehran talks shortly about Components and containers berfore he goes into a codefrenzy :-)  

Components is anything that can appear in a window and containers contains other components. Think of a bag that contains (components and) another bag. Bag in a bag in a...