Finished all but task 5, is 80% percent, enough for approval
parent
23251dbf64
commit
bed4f31d23
|
@ -138,6 +138,7 @@
|
|||
<ClCompile Include="Task1.cpp" />
|
||||
<ClCompile Include="Task2.cpp" />
|
||||
<ClCompile Include="Task3.cpp" />
|
||||
<ClCompile Include="Task4.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="grunnlov.txt" />
|
||||
|
@ -148,6 +149,7 @@
|
|||
<ClInclude Include="Task1.h" />
|
||||
<ClInclude Include="Task2.h" />
|
||||
<ClInclude Include="Task3.h" />
|
||||
<ClInclude Include="Task4.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<ClCompile Include="Task3.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Task4.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="grunnlov_iso-latin-1.txt">
|
||||
|
@ -49,5 +52,8 @@
|
|||
<ClInclude Include="Task3.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Task4.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -6,7 +6,7 @@ CourseCatalog::CourseCatalog()
|
|||
|
||||
void CourseCatalog::addCourse(string code, string name)
|
||||
{
|
||||
courses.insert(code, name);
|
||||
courses[code] = name;
|
||||
}
|
||||
|
||||
void CourseCatalog::removeCourse(string code)
|
||||
|
@ -19,7 +19,13 @@ string CourseCatalog::getCourse(string code)
|
|||
return courses[code];
|
||||
}
|
||||
|
||||
ostream & operator<<(ostream &, const CourseCatalog &)
|
||||
{
|
||||
// TODO: insert return statement here
|
||||
|
||||
ostream& operator<<(ostream & os, const CourseCatalog & cc)
|
||||
{
|
||||
string courses;
|
||||
for (const auto c : cc.courses)
|
||||
{
|
||||
courses += c.first + '\t' + c.second + '\n';
|
||||
}
|
||||
return os << courses;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ class CourseCatalog
|
|||
public:
|
||||
CourseCatalog();
|
||||
friend ostream& operator<<(ostream&, const CourseCatalog&);
|
||||
void addCourse(string code, string name);
|
||||
void addCourse(const string code, string name);
|
||||
void removeCourse(string code);
|
||||
string getCourse(string code);
|
||||
private:
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#include "Task4.h"
|
||||
|
||||
istream & operator>>(istream & is, Temps & t)
|
||||
{
|
||||
double inMax, inMin;
|
||||
is >> inMax >> inMin;
|
||||
if (!is) return is;
|
||||
|
||||
t = Temps{ inMax, inMin };
|
||||
return is;
|
||||
// TODO: insert return statement here
|
||||
}
|
||||
|
||||
ostream & operator<<(ostream & os, vector<Temps>& temps)
|
||||
{
|
||||
for (const auto t : temps)
|
||||
{
|
||||
os << t.max << '\t' << t.min << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
void readTempsFromFile(vector<Temps>& temps, string path)
|
||||
{
|
||||
ifstream ifs{ path };
|
||||
if (!ifs)
|
||||
{
|
||||
error("Cant open file ", path);
|
||||
return;
|
||||
}
|
||||
Temps t;
|
||||
string line;
|
||||
while (getline(ifs, line))
|
||||
{
|
||||
cout << line;
|
||||
istringstream iss{ line };
|
||||
iss >> t;
|
||||
temps.push_back(t);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
#include "std_lib_facilities.h"
|
||||
|
||||
struct Temps {
|
||||
double max, min;
|
||||
};
|
||||
|
||||
istream& operator>>(istream& is, Temps& t);
|
||||
|
||||
ostream& operator<<(ostream& os, vector<Temps>& temps);
|
||||
|
||||
void readTempsFromFile(vector<Temps>& temps, string path);
|
|
@ -2,6 +2,7 @@
|
|||
#include "Task1.h"
|
||||
#include "Task2.h"
|
||||
#include "Task3.h"
|
||||
#include "Task4.h"
|
||||
|
||||
int main(){
|
||||
|
||||
|
@ -10,7 +11,28 @@ int main(){
|
|||
|
||||
//addLineNumber("inn.txt", "out.txt");
|
||||
|
||||
countCharInTxt("grunnlov.txt");
|
||||
//countCharInTxt("grunnlov.txt");
|
||||
|
||||
|
||||
CourseCatalog courses = CourseCatalog();
|
||||
|
||||
courses.addCourse("TDT4100", "Informasjonsteknologi grunnkurs");
|
||||
courses.addCourse("TDT4102", "Prosedyre- og objektorientert programmering");
|
||||
courses.addCourse("TMA4100", "Matematikk 1");
|
||||
courses.addCourse("TDT4102", "C++");
|
||||
|
||||
// map.insert funker ikke
|
||||
|
||||
|
||||
cout << courses;
|
||||
|
||||
vector<Temps> temps;
|
||||
string file = "temperatures.txt";
|
||||
|
||||
readTempsFromFile(temps, file);
|
||||
|
||||
cout << temps;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue