View Single Post
Old 05-29-2012, 07:26 AM   PM User | #6
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
I'm just nearing the end of that same book. Still have my working example of that code:
PHP Code:
class VolcanoRobot {
    
String status;
    
int speed;
    
float temperature;
    
    
void checkTemperature() {
        if (
temperature 660) {
            
status "returning home";
            
speed 5;
        }
    }
    
void showAttributes() {
        
System.out.println("Status: " status);
        
System.out.println("Speed: " speed);
        
System.out.println("Temperature: " temperature);
    }

PHP Code:
class VolcanoApplication {
    public static 
void main(String[] args) {
        
VolcanoRobot dante = new VolcanoRobot();
        
dante.status "exploring";
        
dante.speed 2;
        
dante.temperature 510;
        
        
dante.showAttributes();
        
System.out.println("Increasing speed to 3.");
        
dante.speed 3;
        
dante.showAttributes();
        
System.out.println("Changing temperature to 670.");
        
dante.temperature 670;
        
dante.showAttributes();
        
System.out.println("Checking the temperature.");
        
dante.checkTemperature();
        
dante.showAttributes();
    }

I've used Notepad++, Netbeans and Eclipse. I've definately found Eclipse to be the better of the 3 for Java.
dan-dan is offline   Reply With Quote