A Theory of Socialism and Capitalism