Date: Wed, 12 Mar 2003 19:09:11 -0600 (CST) From: Mark Jacobson To: 810-061-02@uni.edu Subject: PIVs and PCVs and the Die class... Hi Java students, I have seen several students with the error from the following: return Die.getX(); <----- No, no, no. Die is a class, a blueprint. Die is NOT an object. Die is the name of a class. The Die class will have certain PIVs, which might include a dieFrame and a dieBackground The FramedRect object dieFrame that is one ------ of the Private Instance Variables that implements a Die object, is a FramedRect, and thus has available to it the public method getX(), so dieFrame.getX() is legal to say in Java, if dieFrame is an object of type FramedRect. Your Die class will possibly have a Private Class Variable (PCV) instead of a PIV (Private Instance Variable) - - - --- --- - - - if you choose to make your RandomIntGenerator PRIVATE STATIC RandomIntGenerator g = new R I G(1, 6); ------ The keyword static makes it a class variable instead of an ----- instance variable. -------- Does every Die object need its own personal FramedRect and FilledRect and Text object? Yes! Those three things are needed by each Die object, so they are PIVs (private instance variables). If you have 5 Die objects in your program, there will actually be a total of 15 PIVs, at least 15 PIVs. Actually, 20 PIVs, because each Die object also needs its own private int INTEGER variable to remember if it is 1, 2, 3, 4, 5 or 6. So die1, die2, die3, die4 and die5 are the 5 dice needed for Yahtzee. But they are each one of them at least 4 different PIVs, so we have 20 different variables when you look behind the scenes. ---------------------- Does the dieRoller object need to be a PIV? Does each Die object need to have its own person dieRoller RandomIntGenerator? No! All 5 Die object can SHARE 1 randomintgenerator, so the RandomIntGenerator can be a PRIVATE CLASS VARIABLE, PCV, - - - instead of a PIV. Does every lab station in Wright 337 lab need a keyboard? Yes. a chair? Yes. a monitor? Yes. a mouse? Yes. Does every lab station in Wright 337 lab need a printer? NO!!!!! All the PC's in the one lab can share ONE printer. --- But each PC workstation better have its own keyboard, and its own mouse. See you in class. Mark