The flip flop is used for change states over the time using a clock. If you go on wikipwdia you can easily find Flip Flop D description.
You can read this link for learning FSM:
http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Seq/fsm.html
First you learn combinatorysequential logic you have to know basic sequentialcombinatory logic rules. If you don't I reccomend to read something about it.
You can practice using "logicly" software, search it on google. Have fun!