Design and Analysis of Agent Systems by Extended Statecharts