70 likes | 264 Views
CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public. it-sudparis.eu /~gibson/Teaching/CSC7322/. Dice MVC Problem …/~ gibson / Teaching /CSC7322/L6-Dice-MVC-PBL.pdf. A Simple Dice Button Frame. import models.Dice ;
E N D
CSC 7322 : Object OrientedDevelopment J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public.it-sudparis.eu/~gibson/Teaching/CSC7322/ Dice MVC Problem …/~gibson/Teaching/CSC7322/L6-Dice-MVC-PBL.pdf TSP: Software Engineering
A Simple DiceButton Frame importmodels.Dice; importviews.DiceButtonView; importcontrollers.DiceButtonController; publicclassDiceButton { publicstaticvoid main(String args[]) { Dice dm = newDice(6); DiceButtonControllerdc = newDiceButtonController(dm); DiceButtonViewdv = newDiceButtonView(dm, dc); dc.updateView(dv); } } Each time the buttonispressed the button label isupdated TSP: Software Engineering
A more graphicalcanvas package applications; importmodels.Dice; importviews.DiceButtonGraphicsView; importcontrollers.DiceButtonController; publicclassDiceButtonGraphics { publicstaticvoid main(String args[]) { Dice dm = newDice(6); DiceButtonControllerdc = newDiceButtonController(dm); DiceButtonGraphicsViewdv = newDiceButtonGraphicsView(dm, dc); dc.updateView(dv); } } Each time the buttonispressed the button label isupdated and the graphicscanvasrepaintedwith the correct number of spots TSP: Software Engineering
A more graphicalcanvas: separate the controller and view frames package applications; importmodels.Dice; importviews.DiceButtonGraphicsView; importcontrollers.DiceButtonController; publicclassDiceButtonGraphics { publicstaticvoid main(String args[]) { Dice dm = newDice(6); DiceButtonControllerdc = newDiceButtonControllerSeparate(dm); DiceButtonGraphicsViewdv = newDiceButtonGraphicsViewSeparate(dm, dc); dc.updateView(dv); } } Each time the buttonispressed the button label isupdated and the graphicscanvasrepaintedwith the correct number of spots TSP: Software Engineering
A more graphicalcanvas: re-use the pattern for a green 8-sideddice package applications; importmodels.Dice; importviews.DiceButtonGraphicsView; importcontrollers.DiceButtonController; publicclassDiceButtonGraphics { publicstaticvoid main(String args[]) { Dice dm = newDice(8); DiceButtonControllerdc = newDiceButtonControllerSeparate(dm); DiceButtonGraphicsViewdv = newDiceButtonGraphicsViewSeparateGreen(dm, dc); dc.updateView(dv); } } Each time the buttonispressed the button label isupdated and the graphicscanvasrepaintedwith the correct number of spots TSP: Software Engineering
A more graphicalcanvas: 1 button, 2 6-sideddice publicclassDoubleDice_MVC { publicstaticvoid main(String args[]) { finalint SIDES = 6; DiceModel dm1 = newDiceModel(SIDES); DiceModel dm2 = newDiceModel(SIDES); DiceButtonDoubleControllerdc = newDiceButtonDoubleController(dm1,dm2); DiceGraphicsView dv1 = newDiceGraphicsView(dm1); DiceGraphicsView dv2 = newDiceGraphicsView(dm2); } } TSP: Software Engineering
A frequencyhistogram for 2 6-Sideddice How easyisit to extend the dice GUI to add a histogramview of the frequencystatistics: 1 * 6-sideddice 2 * 8-sideddice Focus on using the MVC design pattern, and re-use (re-usability) TSP: Software Engineering