Results 1 to 3 of 3
  1. #1
    arefeh is offline Member
    Join Date
    Dec 2009
    Posts
    76
    Rep Power
    0

    Default swirling becomes false,why?

    Java Code:
    class Liquid {
    
        private int mlVolume;
        private float temperature; // in Celsius
    
        public Liquid() {
            mlVolume = 300;
            temperature = (float) (Math.random() * 100.0);
        }
    
        public float getTemperature() {
            return temperature;
        }
        // Has several other methods, not shown...
    }
    
    
    class Coffee extends Liquid {
    
        private static final float BOILING_POINT = 50.0f; // Celsius
        private boolean swirling;
        private boolean clockwise;
    
        public Coffee(boolean swirling, boolean clockwise) {
            if (getTemperature() >= BOILING_POINT) {
                // Leave swirling at default value: false
                [b]return;[/b]
            }
            this.swirling = swirling;
            if (swirling) {
                this.clockwise = clockwise;
            } // else, leave clockwise at default value: false
        }
        void show()
        {
        	System.out.println("BOILING_POINT "+BOILING_POINT);
        	System.out.println("temperature "+getTemperature());
        	System.out.println("swirling "+swirling);
        	System.out.println("clockwise "+clockwise);
        }
        // Has several methods, not shown,
        // but doesn't override getTemperature()...
        public static void main(String args[])
        {
        	Coffee ob=new Coffee(true,false);
          ob.show();
        }
    }
    Hello
    in above code, what does return do?
    when getTemperature() >= BOILING_POINT, swirling becomes false, why?

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    6

    Default

    Quote Originally Posted by arefeh View Post
    in above code, what does return do?
    It returns - exits the constructor method.

    when getTemperature() >= BOILING_POINT, swirling becomes false, why?
    swirling is false by default, it doesn't become false.

  3. #3
    arefeh is offline Member
    Join Date
    Dec 2009
    Posts
    76
    Rep Power
    0

Similar Threads

  1. If statement executing when false...
    By ribbs2521 in forum New To Java
    Replies: 6
    Last Post: 10-26-2009, 05:19 PM
  2. Replies: 4
    Last Post: 08-11-2009, 11:31 AM
  3. hibernate lazy=False
    By Ed in forum JDBC
    Replies: 2
    Last Post: 07-02-2007, 07:54 PM
  4. Replies: 4
    Last Post: 05-19-2007, 11:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •