Den här förmiddagen roar jag mig med den här sidan; How to use Text Areas.
Tänkte lägga upp koden men internet strular på den andra datorn (ja jag sitter med två datorer samtidigt, hehe).
tisdag 5 juni 2012
måndag 4 juni 2012
TextField, layout, text&graphics
Lecture 21.
TextField, Layout (Grid and Table) and Text & Graphics. Again a lecture with a lot of code. I am going to dive right into that any second now.
TextField, Layout (Grid and Table) and Text & Graphics. Again a lecture with a lot of code. I am going to dive right into that any second now.
Etiketter:
Stanford Uni
Interactors( GUI)
Lecture 20.
GUI - Graphical User Interface
Interactors
A lot of coding in this lecture. I had to change a lot in his code because i don't have access to the Stanfords own library (which what I understand has a lot of methods already written in it to simplify for the students). Anyhow, interactors are buttons, sliders, checkboxes, radio buttons, combo box and text box.
Don't forget to create an instance variable if you need to keep track of the variable between methodcalles.
Ex.
pick = new JComboBox();
......
}
private JComboBox pick;
GUI - Graphical User Interface
Interactors
A lot of coding in this lecture. I had to change a lot in his code because i don't have access to the Stanfords own library (which what I understand has a lot of methods already written in it to simplify for the students). Anyhow, interactors are buttons, sliders, checkboxes, radio buttons, combo box and text box.
Don't forget to create an instance variable if you need to keep track of the variable between methodcalles.
Ex.
pick = new JComboBox();
......
}
private JComboBox pick;
Etiketter:
Stanford Uni
fredag 1 juni 2012
Iterator
Lecture 19.
Iterator
-> lists through set of values
ArrayList
ArrayList<String> name new ArrayList<String>( );
Iterator<String> it = names.iterator( );
//Always ask if there are any values left
while(it.hasNext()){
println(it.next());
}
HashMap
Don't have the values in order.
//You ask for the key and not the corresponding value
Iterator<String> i = phonebook.keySet( ).iterator( );
//And then use the whileloop
If you don't want to create the iterator there is a new way of writing:
for (String name : phonebook.keySet()){
println(name)
}
Iterator
-> lists through set of values
ArrayList
ArrayList<String> name new ArrayList<String>( );
Iterator<String> it = names.iterator( );
//Always ask if there are any values left
while(it.hasNext()){
println(it.next());
}
HashMap
Don't have the values in order.
//You ask for the key and not the corresponding value
Iterator<String> i = phonebook.keySet( ).iterator( );
//And then use the whileloop
If you don't want to create the iterator there is a new way of writing:
for (String name : phonebook.keySet()){
println(name)
}
Etiketter:
Stanford Uni
Interface, Map and HashMap
Lecture 19.
Interface
-> set of methods
-> common functionality among a set of classes
Syntax: public class ClassName implements InterfaceName
Interface is more general than extends.
Map (interface)
Key
Value
An association between a key and a value. Always keysensitive.
Ex. Dictionary - a map
words - key
defintions - value
Ex. Phonebook - a map
names - key
numbers - value
HashMap (class)
-> implements Map
template -> 2 types ( one type for your keys and one for your values)
HashMap<String, Integer> phonebook = new HashMap<String, Integer>( );
Methods most commonly used: put and get, but also remove, containskey and size.
phonebook.put("Mehran", 7236059);
phonebook.put("Jenny", 8675309);
Integer MehranNumber = phonebook.get("Mehran");
phonebook.remove(key); //removes key AND value
phonebook.containskey(key); // returns a boolean
THINK of it as a bag where you put things in pairs. No order.
Interface
-> set of methods
-> common functionality among a set of classes
Syntax: public class ClassName implements InterfaceName
Interface is more general than extends.
Map (interface)
Key
Value
An association between a key and a value. Always keysensitive.
Ex. Dictionary - a map
words - key
defintions - value
Ex. Phonebook - a map
names - key
numbers - value
HashMap (class)
-> implements Map
template -> 2 types ( one type for your keys and one for your values)
HashMap<String, Integer> phonebook = new HashMap<String, Integer>( );
Methods most commonly used: put and get, but also remove, containskey and size.
phonebook.put("Mehran", 7236059);
phonebook.put("Jenny", 8675309);
Integer MehranNumber = phonebook.get("Mehran");
phonebook.remove(key); //removes key AND value
phonebook.containskey(key); // returns a boolean
THINK of it as a bag where you put things in pairs. No order.
Etiketter:
Stanford Uni
Debugging
Lecture 18.
Design - Architect
Coding - Engineer
Testing - Vandal!
Debugging - Detective
Always be a vandal!
Bad values, faulty logic and unwarranted assumptions (ex. feet instead of meters) causes bugs.
- Most of the problems are SIMPLE
- Be systematic
- Don't make assumptions about the problem(s)
- Be critical (< instead of >)
And don't panic!
Use println to find bugs. Ex. before and after a method or writing out variables.
Unit test - test one unit at the time (with values you give)
Design - Architect
Coding - Engineer
Testing - Vandal!
Debugging - Detective
Always be a vandal!
Bad values, faulty logic and unwarranted assumptions (ex. feet instead of meters) causes bugs.
- Most of the problems are SIMPLE
- Be systematic
- Don't make assumptions about the problem(s)
- Be critical (< instead of >)
And don't panic!
Use println to find bugs. Ex. before and after a method or writing out variables.
Unit test - test one unit at the time (with values you give)
Etiketter:
Stanford Uni
Arraylist vs array
Lecture 18.
Arraylist
+ dynamic resized
+ other operations
- less efficient than an array
- syntax is bulky (more errors can occur)
- pre version 5.0
If you have a fixed size (almost) always use an array!
Arraylist
+ dynamic resized
+ other operations
- less efficient than an array
- syntax is bulky (more errors can occur)
- pre version 5.0
If you have a fixed size (almost) always use an array!
Etiketter:
Stanford Uni
Prenumerera på:
Inlägg (Atom)