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(); }
//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()); }
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(); }
//resets DvdDetails to DvdMementoData public void getState(DvdDetails d) { d.setTitleName(mementoTitleName); d.setStars(mementoStars); d.setEncodingRegion(mementoEncodingRegion); }
//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()); }