Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TwiceAsHot
- def initialize(temp, isFarenheit)
- @temperature = temp;
- @isFarenheit = isFarenheit;
- self.getInfo();
- end
- def calculateTwiceAsHot
- if (@isFarenheit) then
- centigrade = (@temperature - 32) * (5 / 9);
- else
- centigrade = @temperature;
- end
- kelvin = centigrade + 287;
- kelvin *= 2;
- centigrade = kelvin - 287;
- if (@isFarenheit) then
- newTemperature = (centigrade * (9 / 5)) + 32;
- else
- newTemperature = centigrade;
- end
- puts "If the temperature were to be twice as hot it would be #{newTemperature} degrees #{@isFarenheit ? 'Farenheit' : 'Centigrade'}.";
- end
- def getInfo
- puts "The temperature is #{@temperature} degrees #{@isFarenheit ? 'Farenheit' : 'Centigrade'}.";
- end
- end
- hot = TwiceAsHot.new(32, false);
- hot.calculateTwiceAsHot();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement