class - Needing help understanding piece of Java code -


i started learn java today, following head first java, 2nd edition, , have code, confusing me. i've got experience in python, new. more specific, don't understand boolean canrecord = false; do.

class dvdplayer {      boolean canrecord = false;      void recorddvd() {         system.out.println("dvd recording");     }     void playdvd() {        system.out.println("dvd playing");    }     }   class dvdplayertestdrive {     public static void main(string [] args) {          dvdplayer d = new dvdplayer();         d.canrecord = true;         d.playdvd();          if (d.canrecord == true) {             d.recorddvd();         }     } }    

on class dvdplayer chose regular dvdplayer cannot record. set false.

if want record either change variable directly, did on class dvdplayertestdrive.

the boolean canrecord = false meant show possible reproduce behaviour of objects. in case have class should represent dvdplayer , know majority of dvdplayers not record.

don't focus on code during first approach object oriented programming (i assume first oop language too).

try understand concepts , ideas behind =)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Python Tornado package error when running server -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -