Skip to content

Commit

Permalink
refactor: メソッドの引き上げ
Browse files Browse the repository at this point in the history
  • Loading branch information
k2works committed Dec 14, 2019
1 parent 39b143b commit ab205e6
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions src/page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -677,22 +677,12 @@ <h1>練習プログラム集</h1>
}
}

class Statement {}
class Statement {
headerString(aCustomer) {}

class TextStatement extends Statement {
headerString(aCustomer) {
return `請求明細 ${aCustomer.name} 様\n`;
}
eachRentalString(aRental) {}

eachRentalString(aRental) {
return `\t${aRental.movie.title}\t${aRental.getCharge()}\n`;
}

footerString(aCustomer) {
let result = `請求額 ${aCustomer.getTotalCharge()}\n`;
result += `獲得ポイント ${aCustomer.getTotalFrequentRenterPoints()}`;
return result;
}
footerString(aCustomer) {}

value(aCustomer) {
let frequentRenterPoints = 0;
Expand All @@ -709,6 +699,22 @@ <h1>練習プログラム集</h1>
}
}

class TextStatement extends Statement {
headerString(aCustomer) {
return `請求明細 ${aCustomer.name} 様\n`;
}

eachRentalString(aRental) {
return `\t${aRental.movie.title}\t${aRental.getCharge()}\n`;
}

footerString(aCustomer) {
let result = `請求額 ${aCustomer.getTotalCharge()}\n`;
result += `獲得ポイント ${aCustomer.getTotalFrequentRenterPoints()}`;
return result;
}
}

class htmlStatement extends Statement {
headerString(aCustomer) {
return `<H1>請求明細 <EM>${aCustomer.name} 様</EM></H1><P>\n`;
Expand All @@ -723,20 +729,6 @@ <h1>練習プログラム集</h1>
result += `獲得ポイント <EM>${aCustomer.getTotalFrequentRenterPoints()}</EM><P>`;
return result;
}

value(aCustomer) {
let frequentRenterPoints = 0;
let result = this.headerString(aCustomer);
aCustomer.rentals.forEach(each => {
frequentRenterPoints += each.getFrequentRenterPoints();

// この貸し出しに関する数値の表示
result += this.eachRentalString(each);
});
result += this.footerString(aCustomer);
// フッタ部分の追加
return result;
}
}
</script>
<script>
Expand Down

0 comments on commit ab205e6

Please sign in to comment.