Computer Science BSc Java Programming Practice 4 Dr

Computer Science BSc: Java Programming Practice 4 Dr. Gábor Pauler, Associate Professor, PTETTK, Room F 104, 6 th Ifjusag str. Pecs, Hungary Skype: gjpauler E-mail: pauler@t-online. hu Facebook and Open FTP sites of the course: https: //www. facebook. com/groups/574936103087671/ ftp: //gamma. ttk. pte. hu/pub/pauler/Java/

Content of the Practice Checking Home Assignment 3: Draw Jackson-diagram of algorithms of group project PRACTICE 4 -1: Define class Elephant with static String VERSION and String name, Integer age, Boolean male (eg. Is it male? ) properties PRACTICE 4 -2: Define its constructor polymorphs (Blank, Named, Full param. ) PRACTICE 4 -3: Define its getters and setters PRACTICE 4 -4: Write static rendezvous meta-constructor method (if there are no any elephant instances yet) PRACTICE 4 -5: Write dynamic mating meta-contructor method (from the viewpoint of an existing elephant instance) PRACTICE 4 -6: Define ancestor class Animal, generalizing behavior of Elephant PRACTICE 4 -7: Define class Tiger as descendant of Animal adding Boolean dangerous property PRACTICE 4 -8: Write dynamic mating meta-constructor (with actual tiger instance) PRACTICE 4 -9: Write setters/getters for additional dangerous property PRACTICE 4 -10: Manual override of method sound. Voice of Animal in Elephant PRACTICE 4 -11: Use earlier defined constructors, getters/setters of classes Elephant, Tiger Home Assignment 4 -1: Pen factory References

4. Practice Tasks 1 Complexity of practice tasks increases gradually: PRACTICE 4 -1: Define class Elephant with static String VERSION and String name, Integer age, Boolean male (eg. Is it male? ) properties PRACTICE 4 -2: Define its constructor polymorphs (Blank, Named, Full param. ) You should take in consderiation that elephants are born at 0 years age Their gender is randomly male or female 50%: 50% PRACTICE 4 -3: Define its getters and setters At setting the age please consider that it should be incremented only with 1 year if the elephant is getting older Besides the normal setters there should be a method birth. Day making the given elephant one year older Elephants can sound. Voice writing it out to console, without getting or setting anything. PRACTICE 4 -4: Write static rendezvous meta-constructor method (if there are no any elephant instances yet) If a boy and a girl elephant make rendezvous, soon a baby elephant will born with 0 years of age, random gender, and its name is concatenated from the parents name It can happen only if boy is a male and girl is a female PRACTICE 4 -5: Write dynamic mating meta-contructor method (from the viewpoint of an existing elephant instance) If there is an existing elephant and it meets with an elephant from the opposite gender, a baby elephant can born according to the rules at the last task

4. Practice Tasks 2 PRACTICE 4 -6: Define ancestor class Animal, generalizing behavior of Elephant Later we need to process tigers’ data also. But instead of manually coding nearly the same things again, dtermine which are the common properties and methods among elephants and tigers and put them in an ancestor class PRACTICE 4 -7: Define class Tiger as descendant of Animal adding Boolean dangerous property PRACTICE 4 -8: Write dynamic mating meta-constructor (with actual tiger instance) The mating rules are almost the same as elephants except that newborn tigers are always not dangerous PRACTICE 4 -9: Write setters/getters for additional dangerous property A tiger sometimes goes. Wild or get domesticated PRACTICE 4 -10: Manual override of method sound. Voice of Animal in Elephant, Tiger Please do not forget that elephants are trumpeting, while tigers are roaring PRACTICE 4 -11: Use earlier defined constructors, getters/setters of classes Elephant, Tiger Try to create them blank, named, full parametered, write out their propertv values to console Solutions: see Zoo project

Content of the Practice Checking Home Assignment 3: Draw Jackson-diagram of algorithms of group project PRACTICE 4 -1: Define class Elephant with static String VERSION and String name, Integer age, Boolean male (eg. Is it male? ) properties PRACTICE 4 -2: Define its constructor polymorphs (Blank, Named, Full param. ) PRACTICE 4 -3: Define its getters and setters PRACTICE 4 -4: Write static rendezvous meta-constructor method (if there are no any elephant instances yet) PRACTICE 4 -5: Write dynamic mating meta-contructor method (from the viewpoint of an existing elephant instance) PRACTICE 4 -6: Define ancestor class Animal, generalizing behavior of Elephant PRACTICE 4 -7: Define class Tiger as descendant of Animal adding Boolean dangerous property PRACTICE 4 -8: Write dynamic mating meta-constructor (with actual tiger instance) PRACTICE 4 -9: Write setters/getters for additional dangerous property PRACTICE 4 -10: Manual override of method sound. Voice of Animal in Elephant PRACTICE 4 -11: Use earlier defined constructors, getters/setters of classes Elephant, Tiger Home Assignment 4 -1: Pen factory References

Home Assignment 4 -1: Pen factory You are suppose to handle the product catalog of a factory manufacturing writing utensils with different function: (pens, pencils, mechanic pencils, fountain pens, marker pens, crayons, brushes, erasers) in single/or multifunction, made from various materials (Metal, ABS, Polycarbonate, Rubber, Wood, Tissue, Hair), in various colors (Black, White, Red, Green, Blue, Magenta, Yellow, Marine, Transparent). Some writing utensils may have refill parts (Pen, Mechanic pencil, Marker, Eraser, Fountain pen). Every part can have dimensions lenght, diameter, writing capacity, case color. Moreover, you are not just handling product catalog of writing utensils and their refills, but track manufactured batches of them. To be able to identify quality problems, batches should contain all data of products/refills and add some additional data: Batch. ID, manufacturing date, best before date, actual fill quantity (it does not always succed to fill the planned quantity, can be more or less), batch status (ORDERED, MANUFACTURED, SCRAP, INVENTORY, SOLD, RETURN, ONSTOCK, INUSE, RELOAD, RECYCLE, DISPOSE) A product type usually has only one instance per year, appearing in the product catalog, while its batches can heve new instance in every day. Please create ancestor/descendant classes, their properties and methods to cover requirements detailed above! Solutions: see Pen project

References Java OOP exercises: https: //www 3. ntu. edu. sg/home/ehchua/programming/java/J 3 f_O OPExercises. html https: //phaariz. files. wordpress. com/2009/06/oop-java-codessummary. pdf

List of Symbols General Symbols: DEF: definition, PRC: process, ALT: alternatives, CYC: cycle, : inference, : contradicts, / : dis/advantage, URL: webaddress DIR: directory, PCK: package, CLS: class, PRP: property MET: method EVN: event EXC: exception Symbols of Graphic User Interface: Aaa|Bbb|-Menu|Submenu, SCR: Screen, FRM: Frame, ID: Unique identifier, BTN: Button, TXB: Textbox, DDN: Dropdown, TAB: Multi. Tabs, CHK: Checkbox RAD: Radio button, TBL: Table COL: Table. Column, LIN: Table. Row, KEY: Keyboard, WRN: Popup warning ERR: Error message Logic Symbols: a&&b: a and b, a&b: binary and, a||b: a or b, a|b: binary or !a: not a Math Symbols: a = b passing value a == b value equals a === b value and type equals a. equals(b) class instance equals != value not equals a / b division or integer division a % b modulus of integer division a + b addition or concatenation Database Symbols: : Entity, ▬◄: 1: many relation ►▬: Many: 1 relation ---▬: independent/dependent side PK: Primary key FK: Foreign key UML Class Diagram Symbols: +PRP: public property, -PRP: private property, #PRP: protected property, ~PCK: package, /CLS: descendant class, Owner◄─Nested: nesting connection Ancestor∆┘Descendant: inheritance conn. Whole♦┘Oblig. Part: obligatory part
- Slides: 8