Пример #1
0
bool Radio::runCommand(std::string input){
    std::string command = "";
    unsigned int i = 0;
    for(i = 0; i < input.length() && input[i] != ' '; ++ i){
	command = command + input[i];
    }
    ++ i;
    std::string restStr = "";
    if(i < input.length()){
	restStr = input.substr(i);	
    }
    if(command == "QUIT"){
	return false;
    }
    if(command == "INIT"){
	init(restStr);
	return true;
    }
    if(command == "ADD"){
	addSong(restStr);
	return true;
    }
    if(command == "RUN"){
	int result = 0;
	result = runFile(restStr);
	if(result == 0){
	    return false;
	}else{
	    return true;
	}
    }
    if(command == "REST"){
	rest(restStr);
	return true;
    }
    if(command == "PLAY"){
	play(restStr);
	return true;
    }
    if(command == "LIKE"){
	like(restStr);
	return true;
    }
    if(command == "DISLIKE"){
	dislike(restStr);
	return true;
    }
    return false;
}
Пример #2
0
int parseLine(std::string line, Time*& time, Hash*& hash, Heap*& heap, Song*& playing){
	if (!line.length()) return 1;

	switch(line[0]){
		case 'I': init(line, time, hash, heap); break;
		case 'R': rest(line, time); break;
		case 'A': add(line, time, hash, heap); break;
		case 'P': play(line, time, hash, heap, playing); break;
		case 'L': like(line, time, hash, heap, playing); break;
		case 'D': dislike(line, time, hash, heap, playing); break;
		default : return 1;
	}

	return 0;
}