-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasciimationFunctions.cpp
55 lines (48 loc) · 1.2 KB
/
asciimationFunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Michael Pham, Brandon Xu
Fall 2022
*/
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
#include <unistd.h>
#include <utility>
#include "adts/list.h"
#include "asciimationFunctions.h"
#include "linkedList.h"
using namespace std;
List<pair<int, string>>* loadMovie(string filename) {
ifstream myFile;
string data;
string data1;
string data2;
LinkedList<pair<int,string>>* list = new LinkedList<pair<int, string>>();
myFile.open(filename);
if(!myFile.is_open()){
throw runtime_error("file " + filename + "failed to open ");
}
string s ="";
getline(myFile, data);
while (!myFile.eof()){
int p=stoi(data);
for (int i =0; i<13; i++){
getline(myFile, data);
s=s+data+"\n";
}
pair<int,string>p1(p,s);
list->insertLast(p1);
getline(myFile, data);
}
return list;
}
void playMovie(List<pair<int, string>>* list) {
while (list->getSize() != 0){
cout << list->getFirst().second << endl;
usleep(list->getFirst().first*1000000/15);
usleep(1000000/15);
system("clear");
list->removeFirst();
}
}