-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexer.sh
executable file
·93 lines (69 loc) · 1.57 KB
/
exer.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
if [ -z "$2" ]
then
echo "Bad args. Example: exer exerciseName className"
exit 1
fi
Ex=$1
Name=$2
UpperName=$(echo "$Name" | tr '[:lower:]' '[:upper:]')
LowerName=$(echo "$Name" | tr '[:upper:]' '[:lower:]')
MAKEFILE=".PHONY: all fclean re
CC = c++
CFLAGS = -Wall -Wextra -Werror
CPP_VERSION = -std=c++98
NAME = $LowerName
SRCS = main.cpp $Name.cpp
HEADERS = $Name.hpp
\$(NAME): \$(SRCS)
@\$(CC) \$(CFLAGS) \$(CPP_VERSION) \$(SRCS) -o \$(NAME)
@echo \"Compiled!. Use\033[0;32m ./\$(NAME)\033[0m\n\"
all: \$(NAME)
fclean:
@rm -f \$(NAME)
clear
re: fclean all
"
HEADER="#ifndef __"$UpperName"_H__
#define __"$UpperName"_H__
#include <iostream>
class $Name{
private:
// your privite members here
public:
$Name ();
$Name (const $Name &a);
~$Name ();
$Name & operator = (const $Name &a);
};
#endif
"
SRC="#include \"$Name.hpp\"
/*--------------------------------------------------------*/
$Name::$Name (){
// your implementation here
}
/*--------------------------------------------------------*/
$Name::$Name (const $Name &a){
// your implementation here
}
/*--------------------------------------------------------*/
$Name::~$Name (){
// your implementation here
}
/*--------------------------------------------------------*/
$Name & $Name::operator = (const $Name &a){
// your implementation here
}
"
MAIN="#include \"$Name.hpp\"
int main(void){
// your main code here
return 0;
}
"
mkdir "$Ex"
echo "$MAKEFILE" > "$Ex/Makefile"
echo "$HEADER" > "$Ex/$Name.hpp"
echo "$SRC" > "$Ex/$Name.cpp"
echo "$MAIN" > "$Ex/main.cpp"