Home HomeJoanna.Chmielewska. .Ksiazka.Poniekad.Kucharska.PL.PDF.eBook.(osloskop.net)adobe.photoshop.7.pl.podręcznik.uzytkownika.[osloskop.net]Adobe.Photoshop.7.PL.podręcznik.uzytkownika.[osloskop.net]Maja.Lidia.Kossakowska. .Siewca.Wiatru.(osloskop.net)Nik Pierumow Ostrze Elfow (3)Moorcock Michael Saga o Elryku Tom 8 Zwiastun BurzyPetersin Thomas Ogrodnik Szoguna00235, f8e131258129ba29543925ab869afd3fAndrzej Sapkowski 1. Krew ElfowMartin George R.R Gra o tron (SCAN dal 908)
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • grabaz.htw.pl
  •  

    [ Pobierz całość w formacie PDF ]
    .Add(sw)End Ifsname = fl.readLineconsole.writeLine(":" + sname)End Whilesort()index = 0End Sub'-------Public Sub setData(ByVal swcol As ArrayList)swimmers = swcolmovefirst()End Sub'-------'Clone dataset from other swimdata objectPublic Sub Clone(ByVal swd As SwimData)Dim swmrs As New ArrayList()Dim i As Integer'copy data from one collection' to anotherFor i = 0 To swimmers.Count - 1swmrs.Add(swimmers(i))Next i'and put into new classswd.setData(swmrs)End Sub'-----'sorting method must be specifiedCopyright © 2001, by James W.Cooper 193'in the child classesPublic MustOverride Sub sort()'-----Public Sub MoveFirst()index = -1End Sub'-----Public Function hasMoreElements() As BooleanReturn (index 0 Then 'separate into first and lastsfrname = nm.substring(0, i)slname = nm.substring(i + 1)Elsesfrname = ""slname = nm 'or just use oneEnd Ifsage = tok.nextToken.ToInt16 'get agesclub = tok.nextToken 'get clubstime = tok.nextToken.ToSingle 'get timessex = tok.nextToken 'get sexEnd SubThen, our TimeSwimData class is very simple, consisting only of the Newmethods and the sort method:Public Class TimeSwimDataInherits SwimData'---------Public Overloads Sub New(ByVal filename As String)MyBase.New(filename)End Sub'---------Public Overloads Sub New()MyBase.new()End Sub'---------'Required sort methodPublic Overrides Sub sort()Dim i, j, max As IntegerDim sw As Swimmermax = swimmers.Count'copy into arrayCopyright © 2001, by James W.Cooper 195Dim sws(max) As Swimmerswimmers.CopyTo(sws)'sort by timeFor i = 0 To max - 1For j = i To max - 1If sws(i).getTime > sws(j).getTime Thensw = sws(i)sws(i) = sws(j)sws(j) = swEnd IfNext jNext i'copy back into new ArrayListswimmers = New Arraylist()For i = 0 To max - 1swimmers.Add(sws(i))Next iEnd SubEnd ClassConsequences of the Prototype PatternUsing the Prototype pattern, you can add and remove classes at run time bycloning them as needed.You can revise the internal data representation of a classat run time based on program conditions.You can also specify new objects at runtime without creating a proliferation of classes.One difficulty in implementing the Prototype pattern in VB is that if the classesalready exist, you may not be able to change them to add the required clonemethods.In addition, classes that have circular references to other classes cannotreally be cloned.Like the registry of Singletons discussed above, you can also create a registry ofPrototype classes which can be cloned and ask the registry object for a list ofpossible prototypes.You may be able to clone an existing class rather thanwriting one from scratch.Copyright © 2001, by James W.Cooper 196Note that every class that you might use as a prototype must itself be instantiated(perhaps at some expense) in order for you to use a Prototype Registry.This canbe a performance drawback.Finally, the idea of having prototype classes to copy implies that you havesufficient access to the data or methods in these classes to change them aftercloning.This may require adding data access methods to these prototype classesso that you can modify the data once you have cloned the class.Thought QuestionsAn entertaining banner program shows a slogan starting at different places on thescreen at different times and in different fonts and sizes.Design the programusing a Prototype pattern.Programs on the CD-ROM\Prototype\AgeplotVB6 age plot\Prototype\DeepProtoVB6 deep prototype\Prototype\OneSexVB6 display by sex\Prototype\SimpleProtoVB6 shallow copy\Prototype\TwoclassAgePlotVB6 age and sex display\Prototype\VBNet\DeepProtVB7 deep prototypeSummary of Creational Patterns" The Factory Pattern is used to choose and return an instance of a class froma number of similar classes based on data you provide to the factory." The Abstract Factory Pattern is used to return one of several groups ofclasses.In some cases it actually returns a Factory for that group of classes.Copyright © 2001, by James W.Cooper 197" The Builder Pattern assembles a number of objects to make a new object,based on the data with which it is presented.Frequently, the choice of whichway the objects are assembled is achieved using a Factory." The Prototype Pattern copies or clones an existing class rather thancreating a new instance when creating new instances is more expensive." The Singleton Pattern is a pattern that insures there is one and only oneinstance of an object, and that it is possible to obtain global access to thatone instance.Copyright © 2001, by James W.Cooper 198Structural PatternsStructural patterns describe how classes and objects can be combined to formlarger structures.The difference between class patterns and object patterns is thatclass patterns describe how inheritance can be used to provide more usefulprogram interfaces [ Pobierz caÅ‚ość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • syriusz777.pev.pl
  •