Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions members/saruwatari/intoroduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
こんにちは
34 changes: 34 additions & 0 deletions members/saruwatarii/phase1/greeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const readline = require('readline');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question('名前を入力してください: ', (name) => {
if (!name.trim()) {
console.error('エラー: 名前が入力されていません');
rl.close();
return;
}

// Process: 名前や時間帯に応じて挨拶を変える
const hour = new Date().getHours();
let greeting;

if (name === '田中') {
greeting = 'いつもお世話になっております!';
} else if (hour >= 5 && hour < 12) {
greeting = 'おはよう';
} else if (hour >= 12 && hour < 18) {
greeting = 'こんにちは';
} else {
greeting = 'こんばんは';
}

const result = `${name}、${greeting}`;

// Output: 名前、挨拶
console.log(result);
rl.close();
});
9 changes: 9 additions & 0 deletions members/saruwatarii/phase1/ipo_card2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## IPOカード

コードを書く**前に**、必ずIPOカードを記入する。

| 項目 | 内容 |
|------|------|
| **Input** |合計金額(税抜)、人数 |
| **Process** |合計金額に 1.1(10%) を掛けてから、人数で割る。 |
| **Output** |「税込合計 〇〇 円、1人あたり △△ 円です」という表示。 |
9 changes: 9 additions & 0 deletions members/saruwatarii/phase1/ipo_card3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## IPOカード

コードを書く**前に**、必ずIPOカードを記入する。

| 項目 | 内容 |
|------|------|
| **Input** |タスク名(文字列)、なし(コマンド実行のみ)、完了したタスクの番号 |
| **Process** |配列(リスト)に新しいタスクを保存する、保存されている配列の中身を番号付きで取り出す、指定された番号のタスクを配列から削除(または完了マーク) |
| **Output** |「タスクを追加しました」と表示、タスク一覧を表示、「〇〇を完了しました」と表示 |
9 changes: 9 additions & 0 deletions members/saruwatarii/phase1/ipo_crad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## IPOカード

コードを書く**前に**、必ずIPOカードを記入する。

| 項目 | 内容 |
|------|------|
| **Input** |名前 |
| **Process** |名前が「田中」なら特別メッセージ、それ以外は時間帯に応じた挨拶をつける |
| **Output** |名前、挨拶 |
66 changes: 66 additions & 0 deletions members/saruwatarii/phase1/todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const readline = require('readline');

// 入力と出力を扱うインターフェースを作成
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

// タスクを保存する配列(メモリ上)
// プログラムを終了すると、この中身は消えます(揮発性)
const tasks = [];

console.log('--- ToDoリストアプリ ---');
console.log('コマンド: add <タスク名>, list, done <タスク名>, search <キーワード>, exit');

// ユーザーの入力を待機するループ
rl.on('line', (line) => {
const args = line.trim().split(' ');
const command = args[0];
const content = args.slice(1).join(' ');

// IPOカードに基づいた処理
if (command === 'add') {
if (content) {
tasks.push(content);
console.log('タスクを追加しました');
} else {
console.log('エラー: タスク名を入力してください');
}
} else if (command === 'list') {
if (tasks.length === 0) {
console.log('タスクはありません');
} else {
console.log('--- タスク一覧 ---');
tasks.forEach((task, index) => {
console.log(`${index + 1}. ${task}`);
});
}
} else if (command === 'done') {
// 部分一致で検索(入力が空でない場合のみ)
const index = content ? tasks.findIndex(task => task.includes(content)) : -1;
if (index !== -1) {
const removedTask = tasks.splice(index, 1);
console.log(`${removedTask}を完了しました`);
} else {
console.log('エラー: そのタスクは見つかりませんでした');
}
} else if (command === 'search') {
if (!content) {
console.log('エラー: 検索キーワードを入力してください');
} else {
const results = tasks.filter(task => task.includes(content));
if (results.length === 0) {
console.log('該当するタスクはありません');
} else {
console.log('--- 検索結果 ---');
results.forEach(task => console.log(task));
}
}
} else if (command === 'exit') {
console.log('アプリを終了します');
rl.close();
} else {
console.log('無効なコマンドです (使えるコマンド: add, list, done, search, exit)');
}
});
21 changes: 21 additions & 0 deletions members/saruwatarii/phase1/warikan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// IPOカードに基づいた割り勘計算機
// 実行例: node warikan.js 1000 3

// Input: コマンドライン引数を受け取る
const totalAmount = Number(process.argv[2]); // 合計金額(税抜)
const people = Number(process.argv[3]); // 人数

// 入力チェック(数値でない場合や、0以下の人数を防ぐ)
if (isNaN(totalAmount) || isNaN(people) || people <= 0) {
console.log("エラー: 正しい数値を入力してください。");
console.log("使い方: node warikan.js <合計金額> <人数>");
process.exit(1);
}

// Process: 消費税計算と割り算
const totalAmountWithTax = Math.floor(totalAmount * 1.1); // 税込合計(切り捨て)
const perPerson = Math.floor(totalAmountWithTax / people); // 1人あたり(切り捨て)
const remainder = totalAmountWithTax % people; // 端数

// Output: 結果の表示
console.log(`税込合計 ${totalAmountWithTax} 円、1人あたり ${perPerson} 円です(端数:${remainder} 円)`);