CSC 216 Lecture Notes - Lecture 11: Finite-State Machine, Decimal Mark, State Pattern

59 views3 pages
29 Sep 2016
School
Course
Professor

Document Summary

Class 11: finite state machines and state pattern. Horner"s rule: a fast method for evaluating polynomials. Fsm to convert a string of acsii characters into real numbers: java. lang. float. parsefloat(string s), given 5x4 3x3 + x2 4x 7 = ((((0 + 5)x-3)x+1)x-4)x-7. Integers are polynomials evaluated at x = 10 : 1092 = 1x3 + 0x2 + 9x + 2, when x = 10, using horner"s rule . Works by converting a digit to its value d" 0" = d. Digits to the right of the decimal point are multiplied by appropriate negative power of. State pattern: a design pattern reliant on fsm that returns a result based on traversing an fsm (while-switch idiom) for a given input: previous examples of fsms aren"t object oriented . In some cases, the state of something may influence the actions of the entire program. How to implement the state pattern: 1) define a state interface/abstract class.

Get access

\$40 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class