Skip to content

Commit

Permalink
同样的手法处理getFrequentRenterPoints,但是出错了
Browse files Browse the repository at this point in the history
  • Loading branch information
chentuo14 committed Mar 7, 2019
1 parent 7eecf5b commit 922443f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
30 changes: 18 additions & 12 deletions ch1_firstCase/ch1_qtCpp/ch1_qtCpp.pro.user
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.4.1, 2019-03-05T17:00:49. -->
<!-- Written by QtCreator 4.4.1, 2019-03-07T07:21:51. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{9e2121f9-3504-4f4a-a688-9aca77101f68}</value>
<value type="QByteArray">{09728a37-8b3d-4168-9ae6-77e0ca09f9aa}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down Expand Up @@ -40,6 +40,7 @@
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
Expand All @@ -58,22 +59,21 @@
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.2 GCC 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.2 GCC 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.gcc_64_kit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{8e8fe84a-b195-4d3c-a8af-57974c56548b}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chen/Downloads/rebuild/ch1_firstCase/build-ch1_qtCpp-Desktop_Qt_5_4_2_GCC_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/myfly2/Documents/BookRebuild/ch1_firstCase/build-ch1_qtCpp-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
Expand Down Expand Up @@ -119,10 +119,10 @@
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
Expand All @@ -141,6 +141,11 @@
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
Expand Down Expand Up @@ -178,13 +183,14 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ch1_qtCpp</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">ch1_qtCpp2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/chen/Documents/mygit/BookRebuild/ch1_firstCase/ch1_qtCpp/ch1_qtCpp.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/myfly2/Documents/BookRebuild/ch1_firstCase/ch1_qtCpp/ch1_qtCpp.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">ch1_qtCpp.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
Expand Down
6 changes: 3 additions & 3 deletions ch1_firstCase/ch1_switch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ int main()
}
std::cout << std::endl;

for(unsigned int i=0;i<numCustomers;++i) {
Customer tempCust = customers[i];
std::cout << tempCust.statement() << std::endl;
auto iter = customers.begin();
for(;iter != customers.end(); ++ iter) {
std::cout << iter->statement() << std::endl;;
}

return 0;
Expand Down
7 changes: 1 addition & 6 deletions ch1_firstCase/ch1_switch/movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ double Movie::getCharge(int daysRented)

int Movie::getFrequentRenterPoints(int daysRented)
{
//积分累加条件:新版本的片子,借的时间大于1天
if((getPriceCode() == 1) && daysRented > 1) {
return 2;
} else {
return 1; //每借一张加1个积分点
}
return _price->getFrequentRenterPoints(daysRented);
}

12 changes: 12 additions & 0 deletions ch1_firstCase/ch1_switch/price.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ double NewReleasePrice::getCharge(int daysRented)
return result;
}

int NewReleasePrice::getFrequentRenterPoints(int daysRented)
{
//积分累加条件:新版本的片子,借的时间大于1天
return (daysRented > 1) ? 2 : 1;
}

int RegularPrice::getPriceCode()
{
return Movie::REGULAR;
Expand All @@ -36,3 +42,9 @@ double RegularPrice::getCharge(int daysRented)
result += (daysRented - 2) * 1.5;
return result;
}


int Price::getFrequentRenterPoints(int daysRented)
{
return 1; //每借一张加1个积分点
}
2 changes: 2 additions & 0 deletions ch1_firstCase/ch1_switch/price.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Price
public:
virtual int getPriceCode() = 0;
virtual double getCharge(int daysRented) = 0;
int getFrequentRenterPoints(int daysRented);
};

class ChildrensPrice : public Price
Expand All @@ -20,6 +21,7 @@ class NewReleasePrice : public Price
{
int getPriceCode();
double getCharge(int daysRented);
int getFrequentRenterPoints(int daysRented);
};

class RegularPrice : public Price
Expand Down

0 comments on commit 922443f

Please sign in to comment.