Skip to content

Instantly share code, notes, and snippets.

eiji.ienaga haru01

Block or report user

Report or block haru01

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View movePayment.js
// https://github.com/j5ik2o/ticket-price-modeling
// 解き方方針: 型で問題を解くよりも、料金表のように日本人の非エンジニアの人も読めて突っ込めるコード記述を目指す.
// 解き方方針: 配列でmap&sortの世界に引き込んで安い料金を選ぶようにする.
// 解いたのは "シネマシティズン" の場合だけ。
// TODO 引数を型にして呼び出しに制約を設けるかはあとで考える。
const movePayment = (ticketType, timeTypes) => {
var payments =
{"シネマシティズン":
{"平日〜20:00": 1000,
View Money.ts
interface Expression {
times(muptiplier: number): Expression;
plus(addend: Expression): Expression;
reduce(bank: Bank, to: string): Money
}
class Money implements Expression {
private _amount: number
private _currency: string
View 20.js
function createReportData(readList, recommendList) {
const reportData = {};
reportData.userName = readList.name;
reportData.readBooks = readList.books
.map(book => {
return {...book, point: point(book)};
});
reportData.total = total(reportData);
return reportData;
View 19.js
const createReportData = require('./createReportData');
function generateReadReport(readList, recommendList) {
const reportData = createReportData(readList, recommendList);
return renderPlainText(reportData);
}
function renderPlainText(reportData) {
let report = `name: ${reportData.userName}\n`;
report += '-----\n';
View 18.js
function generateReadReport(readList, recommendList) {
const reportData = createReportData(readList, recommendList);
return renderPlainText(reportData);
}
function createReportData(readList, recommendList) {
const reportData = {};
reportData.userName = readList.name;
reportData.readBooks = readList.books
.map(book => {
View 17.diff
@@ -1,6 +1,6 @@
function generateReadReport(readList, recommendList) {
const reportData = createReportData(readList, recommendList);
- return renderPlainText(reportData, recommendList);
+ return renderPlainText(reportData);
}
function createReportData(readList, recommendList) {
@@ -42,7 +42,7 @@ function createReportData(readList, recommendList) {
}
View 16.diff
@@ -10,8 +10,14 @@ function createReportData(readList, recommendList) {
.map(book => {
return {...book, point: point(book)};
});
+ reportData.total = total(reportData);
return reportData;
+ function total(reportData) {
+ return reportData.readBooks
+ .reduce((total, book) => total + book.point, 0);
View 15.js
function renderPlainText(reportData, recommendList) {
let report = `name: ${reportData.userName}\n`;
report += '-----\n';
for (let book of reportData.readBooks) {
if (book.times >= 1) {
report += ` - ${book.name}: ${book.point} point\n`;
}
}
report += '-----\n';
report += `total: ${total()} point`;
View 8.start.js
function generateReadReport(readList, recommendList) {
let report = `name: ${readList.name}\n`;
report += '-----\n';
for (let book of readList.books) {
if (book.times >= 1) {
report += ` - ${book.name}: ${point(book)} point\n`;
}
}
report += '-----\n';
report += `total: ${total()} point`;
View 14.js
function createReportData(readList, recommendList) {
const reportData = {};
reportData.userName = readList.name;
reportData.readBooks = readList.books
.map(book => {
return {...book, point: point(book)};
});
return reportData;
function point(readBook) {
You can’t perform that action at this time.