Relational Calculus of Object Systems rCOS) is an OO-language which is equipped with an observation-oriented semantics and a refinement calculus based on the Hoare and He's Unifying Theories of Programming (UTP). In this paper, we give syntactic definitions for class diagrams and sequence diagrams in UML 2.0. Based on these definitions, we give an algorithm for checking the consistency of a class diagram and a sequence diagram. Furthermore, we develop an algorithm to generate rCOS code from any given consistent class diagram and sequence diagram.