示例#1
0
        public static void Main()
        {
            Tapper tap = new Tapper();

            DvdDetails.DvdMemento dvdMementoCaretaker;
            //the Caretaker

            List <string> stars = new List <string>();

            stars.Add("Guy Pearce");
            DvdDetails dvdDetails = new DvdDetails("Memento", stars, '1');

            dvdMementoCaretaker = dvdDetails.createDvdMemento();
            tap.test("Showing initial state of DvdDetails ", dvdDetails.formatDvdDetails(), "DVD: Memento, starring: Guy Pearce, encoding region: 1");

            dvdDetails.addStar("edskdzkvdfb");
            tap.test("Cappuccion on the keyboard!", dvdDetails.formatDvdDetails(), "DVD: Memento, starring: Guy Pearce, edskdzkvdfb, encoding region: 1");

            tap.test("show memento state", dvdMementoCaretaker.showMemento(), "DVD: Memento, starring: Guy Pearce, encoding region: 1");
            //show the memento

            dvdDetails.setDvdMemento(dvdMementoCaretaker);
            //back off changes
            tap.test("show backed off state", dvdDetails.formatDvdDetails(), "DVD: Memento, starring: Guy Pearce, encoding region: 1");
            tap.done();
        }
示例#2
0
 //sets DvdMementoData to DvdDetails
 public void setState(DvdDetails d)
 {
     //Because string are immutable we can just set
     //  the DvdMemento Strings to = the DvdDetail Strings.
     mementoTitleName      = d.getTitleName();
     mementoEncodingRegion = d.getEncodingRegion();
     //However, Lists are not immutable,
     //  so we need to instantiate a new List.
     mementoStars = new List <string>(d.getStars());
 }
示例#3
0
        public static void Main()
        {
            Tapper tap = new Tapper();
               DvdDetails.DvdMemento dvdMementoCaretaker;
               //the Caretaker

               List<string> stars = new List<string>();
               stars.Add("Guy Pearce");
               DvdDetails dvdDetails = new DvdDetails("Memento", stars, '1');
               dvdMementoCaretaker = dvdDetails.createDvdMemento();
               tap.test("Showing initial state of DvdDetails ", dvdDetails.formatDvdDetails(),"DVD: Memento, starring: Guy Pearce, encoding region: 1" );

               dvdDetails.addStar("edskdzkvdfb");
               tap.test("Cappuccion on the keyboard!", dvdDetails.formatDvdDetails(),"DVD: Memento, starring: Guy Pearce, edskdzkvdfb, encoding region: 1");

               tap.test("show memento state", dvdMementoCaretaker.showMemento(),"DVD: Memento, starring: Guy Pearce, encoding region: 1");
               //show the memento

               dvdDetails.setDvdMemento(dvdMementoCaretaker);
               //back off changes
               tap.test("show backed off state", dvdDetails.formatDvdDetails(),"DVD: Memento, starring: Guy Pearce, encoding region: 1");
            tap.done();
        }
示例#4
0
 //resets DvdDetails to DvdMementoData
 public void getState(DvdDetails d)
 {
     d.setTitleName(mementoTitleName);
     d.setStars(mementoStars);
     d.setEncodingRegion(mementoEncodingRegion);
 }
示例#5
0
 //sets DvdMementoData to DvdDetails
 public void setState(DvdDetails d)
 {
     //Because string are immutable we can just set
     //  the DvdMemento Strings to = the DvdDetail Strings.
     mementoTitleName = d.getTitleName();
     mementoEncodingRegion = d.getEncodingRegion();
     //However, Lists are not immutable,
     //  so we need to instantiate a new List.
     mementoStars = new List<string>(d.getStars());
 }
示例#6
0
 //resets DvdDetails to DvdMementoData
 public void getState(DvdDetails d)
 {
     d.setTitleName(mementoTitleName);
     d.setStars(mementoStars);
     d.setEncodingRegion(mementoEncodingRegion);
 }