A castle has the following functions: