Commit b34b5d51 authored by Sergej Chodarev's avatar Sergej Chodarev
Browse files

Add UI for disliking posts

parent 2062b2ef
...@@ -35,26 +35,38 @@ void write_post_ui(wall_t *wall) { ...@@ -35,26 +35,38 @@ void write_post_ui(wall_t *wall) {
} }
} }
void like_post_ui(wall_t *wall) { post_t *select_post_ui(wall_t *wall, char *question) {
int number;
post_t *post;
show_wall_ui(wall); show_wall_ui(wall);
printf("Which post would you like to like? Enter number: "); printf("%s Enter number: ", question);
int number;
scanf("%d", &number); scanf("%d", &number);
empty_input_buffer(); empty_input_buffer();
if ((post = get_post(wall, number)) != NULL) { post_t *post = get_post(wall, number);
like_post(post); if (post == NULL) {
} else {
printf("Invalid post number.\n"); printf("Invalid post number.\n");
} }
return post;
}
void like_post_ui(wall_t *wall) {
post_t *post = select_post_ui(wall, "Which post would you like to like?");
if (post != NULL) {
like_post(post);
}
}
void dislike_post_ui(wall_t *wall) {
post_t *post = select_post_ui(wall, "Which post would you like to dislike?");
if (post != NULL) {
dislike_post(post);
}
} }
void main_ui(wall_t *wall) { void main_ui(wall_t *wall) {
int input; int input;
do { do {
printf("(S)how wall / (W)rite post / (L)ike post / (E)xit: "); printf("(S)how wall / (W)rite post / (L)ike post / (D)islike post / (E)xit: ");
input = getchar(); input = getchar();
empty_input_buffer(); empty_input_buffer();
input = toupper(input); input = toupper(input);
...@@ -69,6 +81,9 @@ void main_ui(wall_t *wall) { ...@@ -69,6 +81,9 @@ void main_ui(wall_t *wall) {
case 'L': case 'L':
like_post_ui(wall); like_post_ui(wall);
break; break;
case 'D':
dislike_post_ui(wall);
break;
} }
} while (input != 'E'); } while (input != 'E');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment