Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b745355
lec3 - Step2.다양한 출력 지원 (#48)
HTMLhead Oct 10, 2018
82e620d
delete. code
crongro Oct 18, 2018
122d665
create todosList.json
dev-dongwon Apr 22, 2019
740e861
create todos.js
dev-dongwon Apr 22, 2019
1aba53d
create app.js for program runnung
dev-dongwon Apr 22, 2019
0392d96
Rix the name of function
dev-dongwon Apr 22, 2019
9c75ce0
excuteCommand 함수 수정 : argument 개수 판별 추가
dev-dongwon Apr 22, 2019
c78ff01
isValidCommand 함수 변경 : obeject argument 추가
dev-dongwon Apr 22, 2019
3300bc8
idGenerator 함수 변경 : 상수가 아닌 인자로 random number 생성
dev-dongwon Apr 22, 2019
9394da2
fix the Equal operator to strcit Equal operator
dev-dongwon Apr 22, 2019
a69f0ed
create todosData.json to load the mock data
dev-dongwon Apr 25, 2019
0fb09e8
create app.js to run todos application
dev-dongwon Apr 25, 2019
a687355
add the module : readLine module
dev-dongwon Apr 25, 2019
06f0dc4
add the program constructor
dev-dongwon Apr 25, 2019
fe7b8ef
add the run function : to run the program
dev-dongwon Apr 25, 2019
8d17131
create commandParser.js file : to parse the user's input String
dev-dongwon Apr 25, 2019
2fb6fa8
add the executeCmd function Object : to execute the command line
dev-dongwon Apr 25, 2019
5123c39
create the instruction.js file : to instruct command
dev-dongwon Apr 25, 2019
bc0d420
add the Instruction module
dev-dongwon Apr 25, 2019
449de3a
implements the CommandParser method to parse the command line
dev-dongwon Apr 25, 2019
56fa389
create utils.js to use common
dev-dongwon Apr 25, 2019
8f4d077
add the getArrByCondition function : get array by condition arguments
dev-dongwon Apr 25, 2019
66e181a
add the modules : data status, utils moudule
dev-dongwon Apr 25, 2019
132ad2d
add the show function to show status of data
dev-dongwon Apr 25, 2019
bb27535
add getRandomId function
dev-dongwon Apr 25, 2019
1cacc05
add the show function
dev-dongwon Apr 25, 2019
bc8f795
add the adding object function
dev-dongwon Apr 25, 2019
acb59f8
add the delete function
dev-dongwon Apr 25, 2019
ad16068
add the update function : update object
dev-dongwon Apr 25, 2019
2a3347d
인자에 따라 async하게 작동할 수 있도록 메서드 추가
dev-dongwon Apr 25, 2019
c6c18dc
add the delay function : utils.js
dev-dongwon Apr 25, 2019
14d326f
create exceptionHadling.js file
dev-dongwon Apr 25, 2019
f7269e2
add the runtimeExceptions
dev-dongwon Apr 25, 2019
5e35248
add the exception handling to run the application
dev-dongwon Apr 25, 2019
eae8617
add the modules to run program
dev-dongwon Apr 25, 2019
04875ac
add the isValidCommand function
dev-dongwon Apr 25, 2019
d85d5d2
add the exception handling about executCmd function
dev-dongwon Apr 25, 2019
481a049
add the module : ExceptionHandling module
dev-dongwon Apr 25, 2019
3a7c33c
fix datas
dev-dongwon Apr 25, 2019
dfe2cef
fix the runProgram function : missing argument
dev-dongwon Apr 25, 2019
b81a446
add the exception handling about add, update function
dev-dongwon Apr 25, 2019
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
Prev Previous commit
Next Next commit
add the adding object function
  • Loading branch information
dev-dongwon committed Apr 25, 2019
commit bc8f795f738b162db2e4bd5faee50ee612517376
67 changes: 40 additions & 27 deletions oop/instruction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,54 @@ const convertedData = JSON.parse(JSON.stringify(originData)).data;
const Utils = require('./utils.js');

function Instruction() {

}

Instruction.prototype = {

show : (status) => {
show: (status) => {
const statusArr = ['all', 'todo', 'doing', 'done'];
if (status === 'all') {
let [numOfTodos, numOfDoings, numOfDones] = [0,0,0];
convertedData.forEach((value) => {
if (value.status === 'todo') numOfTodos++;
else if (value.status === 'doing') numOfDoings++;
else if (value.status === 'done') numOfDones++;
});

if (status === 'all') {
let [numOfTodos, numOfDoings, numOfDones] = [0, 0, 0];

convertedData.forEach((value) => {

if (value.status === 'todo') numOfTodos++;
else if (value.status === 'doing') numOfDoings++;
else if (value.status === 'done') numOfDones++;

});

console.log(`현재상태 : todo: ${numOfTodos}개, doing: ${numOfDoings}개, done: ${numOfDones}개`);

} else if (statusArr.includes(status)) {
const tasks = Utils.prototype.getArrByCondition(convertedData, (val) => { return (status === val.status);});
let message = `${status}리스트 총 ${tasks.length}건 : `;
tasks.forEach( obj => {
message += `'${obj.name}, ${obj.id}번,' `;
});

console.log(message);
}
} else if (statusArr.includes(status)) {
const tasks = Utils.prototype.getArrByCondition(convertedData, (val) => {
return (status === val.status);
});
let message = `${status}리스트 총 ${tasks.length}건 : `;
tasks.forEach(obj => {
message += `'${obj.name}, ${obj.id}번,' `;
});

console.log(message);
}
},

add : () => {},
delete : () => {},
update :() => {}

add: (name, tags) => {
const id = Utils.prototype.getRadomId(99999, 1);
let obj = {
name,
tags,
status: 'todo',
id,
};
convertedData.push(obj);
console.log(`${obj.name} 1개가 추가됐습니다.(id : ${obj.id})`);
},

delete: () => {},
update: () => {}
};

module.exports = Instruction;