DesignPattern/17.IteratorPattern/2.Code/main.cpp

35 lines
747 B
C++
Raw Normal View History

2019-11-03 06:20:17 +00:00
#include <iostream>
#include "Iterator.h"
int main()
{
vector<string> channelList = { "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>", "<EFBFBD>ƾ<EFBFBD>Ƶ<EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD>ӰƵ<EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>", "ũҵƵ<EFBFBD><EFBFBD>", "<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" };
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Television *tv = new Television(channelList);
// <20><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>
Iterator *remoteControl = tv->createIterator();
// ˳<><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
remoteControl->first();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
while (remoteControl->hasNext()){
remoteControl->currentChannel();
remoteControl->next();
}
printf("\n\n");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
remoteControl->last();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
while (remoteControl->hasPrevious()){
remoteControl->currentChannel();
remoteControl->previous();
}
printf("\n\n");
system("pause");
return 0;
}