public static void Main() { teaFlavorFactory = new TeaFlavorFactory(); takeOrders("chai", 2); takeOrders("chai", 2); takeOrders("camomile", 1); takeOrders("camomile", 1); takeOrders("earl grey", 1); takeOrders("camomile", 897); takeOrders("chai", 97); takeOrders("chai", 97); takeOrders("camomile", 3); takeOrders("earl grey", 3); takeOrders("chai", 3); takeOrders("earl grey", 96); takeOrders("camomile", 552); takeOrders("chai", 121); takeOrders("earl grey", 121); for (int i = 0; i < ordersMade; i++) { flavors[i].serveTea(tables[i]); } Tapper tap = new Tapper(); tap.test("Flyweight test", ("total teaFlavor objects made: " + teaFlavorFactory.getTotalTeaFlavorsMade()) , ("total teaFlavor objects made: 3") ); tap.done(); }
static void Main() { Tapper tapper = new Tapper(); String topTitle; DvdCategory comedy = new DvdCategory("Comedy"); comedy.setTopCategoryTitle("Ghost World"); DvdSubCategory comedyChildrens = new DvdSubCategory(comedy, "Childrens"); DvdSubSubCategory comedyChildrensAquatic = new DvdSubSubCategory(comedyChildrens, "Aquatic"); comedyChildrensAquatic.setTopSubSubCategoryTitle( "Sponge Bob Squarepants"); topTitle = comedy.getTopTitle(); tapper.test( "DvdCategory Test", ("The top title for " + comedy.getAllCategories() + " is " + topTitle), "The top title for Comedy is Ghost World"); String topTitle2 = comedyChildrens.getTopTitle(); tapper.test("DvdSubCategory top title test", ("The top title for " + comedyChildrens.getAllCategories() + " is " + topTitle2) , "The top title for Comedy/Childrens is Ghost World"); String topTitle3 = comedyChildrensAquatic.getTopTitle(); tapper.test("DvdSubSubCategory top title test ", "The top title for " + comedyChildrensAquatic.getAllCategories() + " is " + topTitle3 , "The top title for Comedy/Childrens/Aquatic is Sponge Bob Squarepants" ); tapper.done(); }
public static void Main() { Tapper tap = new Tapper(); DvdList fiveShakespeareMovies = new DvdList(); fiveShakespeareMovies.append("10 Things I Hate About You"); fiveShakespeareMovies.append("Shakespeare In Love"); fiveShakespeareMovies.append("O (2001)"); fiveShakespeareMovies.append("American Pie 2"); fiveShakespeareMovies.append("Scotland, PA."); fiveShakespeareMovies.append("Hamlet (2000)"); DvdListIterator fiveShakespeareIterator = fiveShakespeareMovies.createIterator(); int a_num_iterations = 0; while (!fiveShakespeareIterator.isDone()) { a_num_iterations++; fiveShakespeareIterator.next(); } tap.test("First iteration", a_num_iterations , 6 ); fiveShakespeareMovies.delete("American Pie 2"); fiveShakespeareIterator.first(); int b_num_iterations = 0; while (!fiveShakespeareIterator.isDone()) { b_num_iterations++; fiveShakespeareIterator.next(); } tap.test("Second iteration", b_num_iterations , (a_num_iterations-1) ); tap.done(); }
public static void Main() { PotOfTeaInterface potOfTea = new PotOfTeaProxy(); Tapper tap = new Tapper(); tap.test("TestProxy: pouring tea", potOfTea.pourTea() , ("Pouring tea")); tap.done(); }
public static void Main() { Tea teaLeaves = new TeaLeaves(); Tea chaiDecorator = new ChaiDecorator(teaLeaves); Tapper tap = new Tapper(); tap.test("steep chai test", chaiDecorator.steepTea() , ("bay leaf is steeping, cinnamon stick is steeping, ginger is steeping, honey is steeping, soy milk is steeping, vanilla bean is steeping")); tap.done(); }
public static void Main() { FacadeCuppaMaker cuppaMaker = new FacadeCuppaMaker(); FacadeTeaCup teaCup = cuppaMaker.makeACuppa(); Tapper tap = new Tapper(); tap.test("Facade test", teaCup.ToString() , ("A nice cuppa tea!")); tap.done(); }
public static void Main() { DvdStateContext stateContext = new DvdStateContext(); Tapper tap = new Tapper(); tap.test( "State 1 test", stateContext.showName( "Sponge Bob Squarepants - Nautical Nonsense and Sponge Buddies") , ("Sponge*Bob*Squarepants*-*Nautical*Nonsense*and*Sponge*Buddies")); tap.test( "State 2 test", stateContext.showName( "Jay and Silent Bob Strike Back") , ("Jay*and*Silent*Bob*Strike*Back")); tap.test( "State 3 test", stateContext.showName( "Buffy The Vampire Slayer Season 2") , ("Buffy!The!Vampire!Slayer!Season!2")); tap.test( "State 4 test", stateContext.showName( "The Sopranos Season 2") , ("The*Sopranos*Season*2")); tap.done(); }
public static void Main() { AbstractSoupFactory concreteSoupFactory = new BostonConcreteSoupFactory(); Soup soupOfTheDay = MakeSoupOfTheDay(concreteSoupFactory); Tapper tap = new Tapper(); tap.test("Boston soup of the day test " , ("The Soup of the day " + concreteSoupFactory.getFactoryLocation() + " is " + soupOfTheDay.getSoupName() ) , ("The Soup of the day Boston is Tofu Soup")); concreteSoupFactory = new HonoluluConcreteSoupFactory(); soupOfTheDay = MakeSoupOfTheDay(concreteSoupFactory); tap.test("Honolulu soup of the day test " , ("The Soup of the day " + concreteSoupFactory.getFactoryLocation() + " is " + soupOfTheDay.getSoupName() ) , ("The Soup of the day Honolulu is Tofu Soup")); tap.done(); }
public static void Main() { SoupBuffet bostonSoupBuffet = createSoupBuffet(new BostonSoupBuffetBuilder()); Tapper tap = new Tapper(); tap.test("Boston builder test ", ("At the " + bostonSoupBuffet.getSoupBuffetName() + bostonSoupBuffet.getTodaysSoups()) , ("At the Boston Soup Buffet Today's Soups! , Chicken Soup: , ChickenSoup, Clam Chowder: , QuahogChowder, Fish Chowder: , ScrodFishChowder, Minnestrone: , Minestrone, Pasta Fazul: , Pasta Fazul, Tofu Soup: , Tofu Soup, Vegetable Soup: , Vegetable Soup")); SoupBuffet honoluluSoupBuffet = createSoupBuffet(new HonoluluSoupBuffetBuilder()); tap.test("Honolulu builder test ", ("At the " + honoluluSoupBuffet.getSoupBuffetName() + honoluluSoupBuffet.getTodaysSoups()) , ("At the Honolulu Soup Buffet Today's Soups! , Chicken Soup: , ChickenSoup, Clam Chowder: , PacificClamChowder, Fish Chowder: , OpakapakaFishChowder, Minnestrone: , Minestrone, Pasta Fazul: , Pasta Fazul, Tofu Soup: , Tofu Soup, Vegetable Soup: , Vegetable Soup")); tap.done(); }
public static void Main() { Tapper tap = new Tapper(); SoupFactoryMethod sfm = new SoupFactoryMethod(); SoupBuffet soupBuffet = sfm.makeSoupBuffet(); soupBuffet.setSoupBuffetName( sfm.makeBuffetName()); soupBuffet.setChickenSoup( sfm.makeChickenSoup()); soupBuffet.setClamChowder( sfm.makeClamChowder()); soupBuffet.setFishChowder( sfm.makeFishChowder()); soupBuffet.setMinnestrone( sfm.makeMinnestrone()); soupBuffet.setPastaFazul( sfm.makePastaFazul()); soupBuffet.setTofuSoup( sfm.makeTofuSoup()); soupBuffet.setVegetableSoup( sfm.makeVegetableSoup()); tap.test("Base Soup Factory Method", ("At the " + soupBuffet.getSoupBuffetName() + soupBuffet.getTodaysSoups()) , ("At the Soup Buffet Today's Soups! , Chicken Soup: , ChickenSoup, Clam Chowder: , ClamChowder, Fish Chowder: , FishChowder, Minnestrone: , Minestrone, Pasta Fazul: , Pasta Fazul, Tofu Soup: , Tofu Soup, Vegetable Soup: , Vegetable Soup") ); SoupFactoryMethod bsfm = new BostonSoupFactoryMethodSubclass(); SoupBuffet bsb = bsfm.makeSoupBuffet(); bsb.setSoupBuffetName( bsfm.makeBuffetName()); bsb.setChickenSoup( bsfm.makeChickenSoup()); bsb.setClamChowder( bsfm.makeClamChowder()); bsb.setFishChowder( bsfm.makeFishChowder()); bsb.setMinnestrone( bsfm.makeMinnestrone()); bsb.setPastaFazul( bsfm.makePastaFazul()); bsb.setTofuSoup( bsfm.makeTofuSoup()); bsb.setVegetableSoup( bsfm.makeVegetableSoup()); tap.test("Boston Soup Factory Method", ("At the " + bsb.getSoupBuffetName() + bsb.getTodaysSoups()) , ("At the Boston Soup Buffet Today's Soups! , Chicken Soup: , ChickenSoup, Clam Chowder: , QuahogChowder, Fish Chowder: , ScrodFishChowder, Minnestrone: , Minestrone, Pasta Fazul: , Pasta Fazul, Tofu Soup: , Tofu Soup, Vegetable Soup: , Vegetable Soup") ); SoupFactoryMethod hsfm = new HonoluluSoupFactoryMethodSubclass(); SoupBuffet hsb = hsfm.makeSoupBuffet(); hsb.setSoupBuffetName( hsfm.makeBuffetName()); hsb.setChickenSoup( hsfm.makeChickenSoup()); hsb.setClamChowder( hsfm.makeClamChowder()); hsb.setFishChowder( hsfm.makeFishChowder()); hsb.setMinnestrone( hsfm.makeMinnestrone()); hsb.setPastaFazul( hsfm.makePastaFazul()); hsb.setTofuSoup( hsfm.makeTofuSoup()); hsb.setVegetableSoup( hsfm.makeVegetableSoup()); tap.test( "Honolulu Factory Method test ", ("At the " + hsb.getSoupBuffetName() + hsb.getTodaysSoups()) , ("At the Honolulu Soup Buffet Today's Soups! , Chicken Soup: , ChickenSoup, Clam Chowder: , PacificClamChowder, Fish Chowder: , OpakapakaFishChowder, Minnestrone: , Minestrone, Pasta Fazul: , Pasta Fazul, Tofu Soup: , Tofu Soup, Vegetable Soup: , Vegetable Soup") ); tap.done(); }
public static void Main() { Tapper tap = new Tapper(); SingleSpoon spoonForFirstPerson = SingleSpoon.getTheSpoon(); tap.test("Create first spoon ", spoonForFirstPerson , spoonForFirstPerson ); SingleSpoon spoonForSecondPerson = SingleSpoon.getTheSpoon(); tap.test("Second person getting a spoon, shouldn't be able to", spoonForSecondPerson == null); SingleSpoon.returnTheSpoon(); tap.test("The spoon was returned", spoonForFirstPerson != null ); spoonForSecondPerson = SingleSpoon.getTheSpoon(); tap.test("Second person getting a spoon", spoonForSecondPerson != null); tap.done(); }
public static void Main() { Tapper tap = new Tapper(); TeaCup teaCup = new TeaCup(); TeaBag teaBag = new TeaBag(); teaCup.steepTeaBag(teaBag); tap.test("Steeping tea bag ", teaBag.teaBagIsSteeped, true ); LooseLeafTea looseLeafTea = new LooseLeafTea(); TeaBall teaBall = new TeaBall(looseLeafTea); teaCup.steepTeaBag(teaBall); tap.test("Steeping loose leaf tea", teaBag.teaBagIsSteeped, true); tap.done(); }
public static void Main() { DvdInterpreterContext dvdInterpreterContext = new DvdInterpreterContext(); dvdInterpreterContext.addTitle("Caddy Shack"); dvdInterpreterContext.addTitle("Training Day"); dvdInterpreterContext.addTitle("Hamlet"); dvdInterpreterContext.addActor("Ethan Hawke"); dvdInterpreterContext.addActor("Denzel Washington"); dvdInterpreterContext.addTitleAndActor( new TitleAndActor("Hamlet", "Ethan Hawke")); dvdInterpreterContext.addTitleAndActor( new TitleAndActor("Training Day", "Ethan Hawke")); dvdInterpreterContext.addTitleAndActor( new TitleAndActor("Caddy Shack", "Ethan Hawke")); dvdInterpreterContext.addTitleAndActor( new TitleAndActor("Training Day", "Denzel Washington")); DvdInterpreterClient dvdInterpreterClient = new DvdInterpreterClient(dvdInterpreterContext); Tapper tap = new Tapper(); tap.test( "interpreting show actor: " , dvdInterpreterClient.interpret( "show actor") , "Query Result: Ethan Hawke, Denzel Washington" ); tap.test( "interpreting show actor for title : " , dvdInterpreterClient.interpret( "show actor for title ") , "Query Result: " ); tap.test( "interpreting show actor for title <Training Day>: " , dvdInterpreterClient.interpret( "show actor for title <Training Day>") , "Query Result: Ethan Hawke, Denzel Washington" ); tap.test( "interpreting show title: " , dvdInterpreterClient.interpret( "show title") , "Query Result: Caddy Shack, Training Day, Hamlet" ); tap.test( "interpreting show title for actor : " , dvdInterpreterClient.interpret( "show title for actor ") , "Query Result: " ); tap.test( "interpreting show title for actor <Ethan Hawke>: " , dvdInterpreterClient.interpret( "show title for actor <Ethan Hawke>") , "Query Result: Hamlet, Training Day, Caddy Shack" ); tap.done(); }
public static void Main() { TitleInfo bladeRunner = new DvdTitleInfo("Blade Runner", "Harrison Ford", '1'); TitleInfo electricSheep = new BookTitleInfo("Do Androids Dream of Electric Sheep?", "Phillip K. Dick"); TitleInfo sheepRaider = new GameTitleInfo("Sheep Raider"); Tapper tap = new Tapper(); tap.test("Testing bladeRunner " , bladeRunner.ProcessTitleInfo().ToString() , "DVD: Blade Runner, starring Harrison Ford "); tap.test("Testing electricSheep " , electricSheep.ProcessTitleInfo().ToString() , "Book: Do Androids Dream of Electric Sheep?, Author: Phillip K. Dick "); tap.test("Testing sheepRaider " , sheepRaider.ProcessTitleInfo().ToString() , "Game: Sheep Raider "); tap.done(); }
public static void Main() { Tapper tap = new Tapper(); PrototypeFactory prototypeFactory = new PrototypeFactory(new SoupSpoon(), new SaladFork()); Spoon spoon = prototypeFactory.makeSpoon(); Fork forky = prototypeFactory.makeFork(); tap.test("Getting the Spoon and Fork name:", ("Spoon: " + spoon.getSpoonName() + ", Fork: " + forky.getForkName()) , ("Spoon: Soup Spoon, Fork: Salad Fork") ); prototypeFactory = new PrototypeFactory(new SaladSpoon(), new SaladFork()); spoon = prototypeFactory.makeSpoon(); forky = prototypeFactory.makeFork(); tap.test("Creating a Prototype Factory with a SaladSpoon and a SaladFork", ("Spoon: " + spoon.getSpoonName() + ", Fork: " + forky.getForkName()) , ("Spoon: Salad Spoon, Fork: Salad Fork") ); tap.done(); }
public static void Main() { DvdMediator dvdMediator = new DvdMediator(); DvdLowercaseTitle dvdLower = new DvdLowercaseTitle("Mulholland Dr.", dvdMediator); DvdUpcaseTitle dvdUp = new DvdUpcaseTitle(dvdLower, dvdMediator); Tapper tap = new Tapper(); tap.test("Lowercase LC title :" , dvdLower.getLowercaseTitle().ToString(),"mulholland dr.".ToString()); tap.test("Lowercase super title :" , dvdLower.getTitle().ToString(),"Mulholland Dr.".ToString()); tap.test("Upcase UC title :" , dvdUp.getUpcaseTitle().ToString(),"MULHOLLAND DR.".ToString()); tap.test("Upcase super title :" , dvdUp.getTitle().ToString(),"Mulholland Dr.".ToString()); dvdLower.setSuperTitleLowercase(); tap.test("Lowercase LC title :" , dvdLower.getLowercaseTitle(),"mulholland dr."); tap.test("Lowercase super title :" , dvdLower.getTitle(),"mulholland dr."); tap.test("Upcase UC title :" , dvdUp.getUpcaseTitle(),"MULHOLLAND DR."); tap.test("Upcase super title :" , dvdUp.getTitle(),"mulholland dr."); tap.done(); }
public static void Main() { DvdReleaseByCategory btvs = new DvdReleaseByCategory("Buffy the Vampire Slayer"); DvdReleaseByCategory simpsons = new DvdReleaseByCategory("The Simpsons"); DvdReleaseByCategory sopranos = new DvdReleaseByCategory("The Sopranos"); DvdReleaseByCategory xfiles = new DvdReleaseByCategory("The X-Files"); DvdSubscriber jsopra = new DvdSubscriber("Junior Soprano"); DvdSubscriber msimps = new DvdSubscriber("Maggie Simpson"); DvdSubscriber rgiles = new DvdSubscriber("Rupert Giles"); DvdSubscriber smulde = new DvdSubscriber("Samantha Mulder"); DvdSubscriber wrosen = new DvdSubscriber("Willow Rosenberg"); btvs.addSubscriber(rgiles); btvs.addSubscriber(wrosen); simpsons.addSubscriber(msimps); sopranos.addSubscriber(jsopra); xfiles.addSubscriber(smulde); xfiles.addSubscriber(wrosen); DvdRelease btvsS2 = new DvdRelease("DVDFOXBTVSS20", "Buffy The Vampire Slayer Season 2", 2002, 06, 11); DvdRelease simpS2 = new DvdRelease("DVDFOXSIMPSO2", "The Simpsons Season 2", 2002, 07, 9); DvdRelease soprS2 = new DvdRelease("DVDHBOSOPRAS2", "The Sopranos Season 2", 2001, 11, 6); DvdRelease xfilS5 = new DvdRelease("DVDFOXXFILES5", "The X-Files Season 5", 2002, 04, 1); Tapper tap = new Tapper(); tap.test("New dvd release test 1", btvs.newDvdRelease(btvsS2),"Hello Rupert Giles, subscriber to the Buffy the Vampire Slayer DVD release list.\nThe new Dvd Buffy The Vampire Slayer Season 2 will be released on 6/11/2002.\nHello Willow Rosenberg, subscriber to the Buffy the Vampire Slayer DVD release list.\nThe new Dvd Buffy The Vampire Slayer Season 2 will be released on 6/11/2002."); tap.test("New dvd release test 2", simpsons.newDvdRelease(simpS2),"Hello Maggie Simpson, subscriber to the The Simpsons DVD release list.\nThe new Dvd The Simpsons Season 2 will be released on 7/9/2002."); tap.test("New dvd release test 3", sopranos.newDvdRelease(soprS2),("Hello Junior Soprano, subscriber to the The Sopranos DVD release list.\nThe new Dvd The Sopranos Season 2 will be released on 11/6/2001.")); tap.test("New dvd release test 4", xfiles.newDvdRelease(xfilS5),("Hello Samantha Mulder, subscriber to the The X-Files DVD release list.\nThe new Dvd The X-Files Season 5 will be released on 4/1/2002.\nHello Willow Rosenberg, subscriber to the The X-Files DVD release list.\nThe new Dvd The X-Files Season 5 will be released on 4/1/2002.")); tap.test("Remove subscriber test", xfiles.removeSubscriber(wrosen) , true); xfilS5.updateDvdReleaseDate(2002, 5, 14); tap.test("Update dvd test", xfiles.updateDvd(xfilS5),("Hello Samantha Mulder, subscriber to the The X-Files DVD release list.\nThe following DVDs release has been revised: The X-Files Season 5 will be released on 5/14/2002.")); tap.done(); }
public static void Main() { DvdName jayAndBob = new DvdName("Jay and Silent Bob Strike Back"); DvdName spongeBob = new DvdName("Sponge Bob Squarepants - Nautical Nonsense and Sponge Buddies"); Tapper t = new Tapper(); CommandAbstract bobStarsOn = new DvdCommandNameStarsOn(jayAndBob); //CommandAbstract bobStarsOff = new DvdCommandNameStarsOff(jayAndBob); CommandAbstract spongeStarsOn = new DvdCommandNameStarsOn(spongeBob); CommandAbstract spongeStarsOff = new DvdCommandNameStarsOff(spongeBob); bobStarsOn.execute(); spongeStarsOn.execute(); t.test( "stars on", jayAndBob.ToString() , "DVD: Jay*and*Silent*Bob*Strike*Back"); t.test( "stars on 2 " , spongeBob.ToString() , "DVD: Sponge*Bob*Squarepants*-*Nautical*Nonsense*and*Sponge*Buddies"); spongeStarsOff.execute(); t.test("sponge stars off", jayAndBob.ToString() , "DVD: Jay*and*Silent*Bob*Strike*Back"); t.test("sponge stars off 2", spongeBob.ToString() , "DVD: Sponge Bob Squarepants - Nautical Nonsense and Sponge Buddies"); t.done(); }
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(); }
public static void Main() { Tapper tap = new Tapper(); TeaBags tinOfTeaBags = new TinOfTeaBags("tin of tea bags"); TeaBags teaBag1 = new OneTeaBag("tea bag 1"); tap.test("Teabag1 count ", teaBag1.countTeaBags() , 1 ); TeaBags teaBag2 = new OneTeaBag("tea bag 2"); tap.test("Teabag2 count ", teaBag2.countTeaBags() , 1 ); tap.test( "TinOfTeaBags add teabag1 ", tinOfTeaBags.add(teaBag1), true); tap.test( "TinOfTeaBags add teabag2 ", tinOfTeaBags.add(teaBag2), true ); tap.test("TinOfTeaBags count after teabag1 and teabag2 adds", ("The tinOfTeaBags now has " + tinOfTeaBags.countTeaBags() + " tea bags in it.") , ("The tinOfTeaBags now has 2 tea bags in it.")); TeaBags smallTinOfTeaBags = new TinOfTeaBags("small tin of tea bags"); tap.test("Small tin count ", smallTinOfTeaBags.countTeaBags() , 0 ); TeaBags teaBag3 = new OneTeaBag("tea bag 3"); tap.test("Putting teaBag3 in smallTinOfTeaBags", smallTinOfTeaBags.add(teaBag3), true ); tap.test("small tin count after 1 add ", smallTinOfTeaBags.countTeaBags() , 1 ); tap.test( "Putting smallTinOfTeaBags in tinOfTeaBags", tinOfTeaBags.add(smallTinOfTeaBags), true ); tap.test( "TinOfTeaBags count before removal ", ("The tinOfTeaBags now has " + tinOfTeaBags.countTeaBags() + " tea bags in it.") , ("The tinOfTeaBags now has 3 tea bags in it.")); tap.test("Removing teaBag2 from tinOfTeaBags", tinOfTeaBags.remove(teaBag2), true ); tap.test("TinOfTeaBags count after removal.", ("The tinOfTeaBags now has " + tinOfTeaBags.countTeaBags() + " tea bags in it.") , ("The tinOfTeaBags now has 2 tea bags in it.")); tap.done(); }
public static void Main() { DvdNameContext allCapContext = new DvdNameContext('C'); DvdNameContext theEndContext = new DvdNameContext('E'); DvdNameContext spacesContext = new DvdNameContext('S'); List<string> dvdNames = new List<string>(); dvdNames.Add("Jay and Silent Bob Strike Back"); dvdNames.Add("The Fast and the Furious"); dvdNames.Add( "The Others"); char replaceChar = '*'; Tapper tap = new Tapper(); tap.test("Testing formatting with all caps", allCapContext.formatDvdNames(dvdNames) , ("JAY AND SILENT BOB STRIKE BACK, THE FAST AND THE FURIOUS, THE OTHERS") ); tap.test( "Testing formatting with beginning the at end", theEndContext.formatDvdNames(dvdNames) , ("Jay and Silent Bob Strike Back, Fast and the Furious, The, Others, The") ); tap.test("Testing formatting with all spaces replaced with " + replaceChar, spacesContext.formatDvdNames(dvdNames, replaceChar) , ("Jay*and*Silent*Bob*Strike*Back, The*Fast*and*the*Furious, The*Others") ); tap.done(); }
public static void Main() { AbstractTitleInfo bladeRunner = new DvdInfo("Blade Runner", "Harrison Ford", '1'); AbstractTitleInfo electricSheep = new BookInfo("Do Androids Dream of Electric Sheep?", "Phillip K. Dick"); AbstractTitleInfo sheepRaider = new GameInfo("Sheep Raider"); TitleBlurbVisitor titleLongBlurbVisitor = new TitleLongBlurbVisitor(); Tapper tap = new Tapper(); bladeRunner.accept(titleLongBlurbVisitor); tap.test( "Testing bladeRunner long " , titleLongBlurbVisitor.getTitleBlurb() , ("LB-DVD: Blade Runner, starring Harrison Ford, encoding region: 1")); electricSheep.accept(titleLongBlurbVisitor); tap.test( "Testing electricSheep long " , titleLongBlurbVisitor.getTitleBlurb() , "LB-Book: Do Androids Dream of Electric Sheep?, Author: Phillip K. Dick"); sheepRaider.accept(titleLongBlurbVisitor); tap.test( "Testing sheepRaider long " , titleLongBlurbVisitor.getTitleBlurb() , "LB-Game: Sheep Raider"); TitleBlurbVisitor titleShortBlurbVisitor = new TitleShortBlurbVisitor(); bladeRunner.accept(titleShortBlurbVisitor); tap.test( "Testing bladerunner short " , titleShortBlurbVisitor.getTitleBlurb() , "SB-DVD: Blade Runner"); electricSheep.accept(titleShortBlurbVisitor); tap.test( "Testing electricSheep short " , titleShortBlurbVisitor.getTitleBlurb() , "SB-Book: Do Androids Dream of Electric Sheep?"); sheepRaider.accept(titleShortBlurbVisitor); tap.test( "Testing sheepRaider short " , titleShortBlurbVisitor.getTitleBlurb() , "SB-Game: Sheep Raider"); }