Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
54e1597
Start of project, main added.
gitmajo Jan 25, 2019
d2d7d03
travis added
gitmajo Jan 25, 2019
d9d1efd
CLASS PERSON
majkel-space Jan 25, 2019
a33f0b5
README added
gitmajo Jan 25, 2019
c0c04da
CLASS PERSON - reviev correction
majkel-space Jan 25, 2019
a604590
Merge pull request #1 from gitmajo/majkel
gitmajo Jan 25, 2019
c9eea62
Empty Database files added.
gitmajo Jan 26, 2019
7714274
travis modified for separate cpp files
gitmajo Jan 26, 2019
4c07628
printDatabase added
gitmajo Jan 26, 2019
06ac1de
DataBase new methods addPerson & sortByLastName
majkel-space Jan 26, 2019
002381e
New method remove Person by personalID
majkel-space Jan 26, 2019
236c7a4
polymorphic getInfo added
gitmajo Jan 27, 2019
eaf4763
min example with sstream
gitmajo Jan 27, 2019
a2e6766
first version of printDatabase
gitmajo Jan 27, 2019
4f90303
small corrections
gitmajo Jan 27, 2019
201365e
DataBase new methods addPerson & sortByLastName
majkel-space Jan 26, 2019
550a523
polymorphic getInfo added
gitmajo Jan 27, 2019
15f1110
min example with sstream
gitmajo Jan 27, 2019
8db8bdb
first version of printDatabase
gitmajo Jan 27, 2019
057acbb
small corrections
gitmajo Jan 27, 2019
6e124d9
sortBySalary() added
gitmajo Jan 27, 2019
66ad37f
Merge branch 'master' into przemek
gitmajo Jan 27, 2019
54c8f24
Merge pull request #4 from gitmajo/przemek
gitmajo Jan 27, 2019
9d6e512
Reformat of code to default vim style
gitmajo Jan 27, 2019
ae092e7
saveToFile() added
gitmajo Jan 27, 2019
c555a07
Passing by value changed to passing by reference
gitmajo Jan 28, 2019
deee056
loadFromFile() added
gitmajo Jan 28, 2019
88e61aa
setSalary added
gitmajo Jan 28, 2019
b0067df
New method remove Person by personalID
majkel-space Jan 26, 2019
05b2ae5
Sort by StudentID
majkel-space Jan 28, 2019
24f81e2
Merge branch 'majkel' of https://github.com/gitmajo/UniversityDatabas…
majkel-space Jan 28, 2019
57c1474
sortBySalary() modified, dynamic_cast added
gitmajo Jan 28, 2019
bd9fb03
Formating changes after review
majkel-space Jan 28, 2019
6a72360
Merge pull request #2 from gitmajo/majkel
gitmajo Jan 28, 2019
b227fd8
Merge branch 'master' into przemek
gitmajo Jan 28, 2019
6e9b449
fix problems from merge
gitmajo Jan 28, 2019
bf6eb71
Merge pull request #5 from gitmajo/przemek
gitmajo Jan 28, 2019
c79f15e
searchByLastName - in progress
majkel-space Jan 28, 2019
9703004
checkPersonalID() added - initial version
gitmajo Jan 29, 2019
5808a9d
Search by last name and personal ID
majkel-space Jan 29, 2019
7c096be
validatePersonalID() added, version in namespace
gitmajo Jan 29, 2019
88044c2
searchByLastName, searchByPersonalID, sortByStudentID
majkel-space Jan 29, 2019
d83c74a
checkPersonalID() added - initial version
gitmajo Jan 29, 2019
cea3a06
validatePersonalID() added, version in namespace
gitmajo Jan 29, 2019
3380753
Code formating
majkel-space Jan 29, 2019
c42dbe4
Merge branch 'master' into majkel
gitmajo Jan 29, 2019
d5aa68e
Merge pull request #7 from gitmajo/majkel
gitmajo Jan 29, 2019
052d3d6
Fix after merge. Code format improved.
gitmajo Jan 29, 2019
dc3c0c3
Merge branch 'master' of https://github.com/gitmajo/UniversityDatabas…
gitmajo Jan 30, 2019
ec8c035
modifySalary(), modifyAddress(), setAddress() added.
gitmajo Jan 30, 2019
80c40cb
Merge branch 'przemek'
gitmajo Jan 30, 2019
52832bb
new calls added to main
gitmajo Jan 30, 2019
2d66ea3
new calls added to main
gitmajo Jan 30, 2019
f488804
CMakeLists.txt improved
gitmajo Jan 30, 2019
be20f0f
Merge branch 'master' of https://github.com/gitmajo/UniversityDatabas…
gitmajo Jan 30, 2019
cd712cf
searchByStudentID, removeByStudentID
majkel-space Jan 30, 2019
19dbc44
sortByPersonalID
majkel-space Jan 30, 2019
5ff743a
modifySalary() argument changed
gitmajo Jan 30, 2019
ac61e92
Merge branch 'master' of https://github.com/gitmajo/UniversityDatabas…
gitmajo Jan 30, 2019
f04a4b0
removeByPersonalID() call added to main
gitmajo Jan 30, 2019
5c767ff
Merge branch 'przemek'
gitmajo Jan 30, 2019
43c86e0
Change of code architecture. Classes separated to new files.
gitmajo Jan 31, 2019
7028e32
SmartPtrs added
gitmajo Jan 31, 2019
3aeff1f
Aliases added, to make code more clean
gitmajo Jan 31, 2019
42ec01d
src and include dirs added, CmakeLists.txt improved
gitmajo Feb 2, 2019
07fb32c
travis will use CMake now
gitmajo Feb 2, 2019
7f437cd
travis fix - typo
gitmajo Feb 2, 2019
545a3e8
Gender changed from bool to enum
gitmajo Feb 2, 2019
53691d5
database filename saved in variable
gitmajo Feb 2, 2019
e0028ad
Code format improved - indentation
gitmajo Feb 2, 2019
9a958dd
src and include dirs added, CmakeLists.txt improved
gitmajo Feb 2, 2019
c9e3107
travis will use CMake now
gitmajo Feb 2, 2019
6df7527
travis fix - typo
gitmajo Feb 2, 2019
599610c
Gender changed from bool to enum
gitmajo Feb 2, 2019
f3fa3d5
database filename saved in variable
gitmajo Feb 2, 2019
802efec
Code format improved - indentation
gitmajo Feb 2, 2019
d180560
dynamic_cast replaced with virtual functions, writToFile() / readToFi…
gitmajo Feb 3, 2019
5a04dc2
Merge branch 'master' into przemek
gitmajo Feb 3, 2019
4b92702
Merge pull request #26 from gitmajo/przemek
gitmajo Feb 3, 2019
b15c94e
private members renamed - name_
gitmajo Feb 3, 2019
eb57f76
small correction in comment
gitmajo Feb 3, 2019
a46e31a
Merge pull request #27 from gitmajo/przemek
gitmajo Feb 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: cpp
compiler: gcc
dist: trusty

before_install:
# C++14
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq

install:
# C++14
- sudo apt-get install -qq g++-6
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90

script:
- mkdir build
- cd build
- cmake ..
- make
- ./universityDatabase
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.1)
project(universityDatabase)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include_directories(include)

set(SOURCES
src/Database.cpp
src/Employee.cpp
src/Person.cpp
src/PersonalID.cpp
src/Student.cpp
src/main.cpp
)

set(HEADER_FILES
include/Database.hpp
include/Employee.hpp
include/Person.hpp
include/PersonalID.hpp
include/Student.hpp
)

add_compile_options(-Wall -Wextra -Werror -Wpedantic)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADER_FILES})
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# UniversityDatabase
[![Build Status](https://travis-ci.org/gitmajo/UniversityDatabase.svg?branch=master)](https://travis-ci.org/gitmajo/UniversityDatabase)
48 changes: 48 additions & 0 deletions include/Database.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once
#include <string>
#include <vector>
#include <memory>
#include "Person.hpp"

using personIter = std::vector<std::shared_ptr<Person>>::iterator;
using personPtr = std::shared_ptr<Person>;

class Database
{
private:
std::vector<personPtr> data_ {};
constexpr static auto dbFilename = "../database.txt"; //literal
bool parseLineByLine(std::ifstream& ifs);
bool writeLineByLine(std::ofstream& ofs);
public:
personIter searchByLastName(const std::string& lastName);
personIter searchByPersonalID(const unsigned long long& personalID);
personIter searchByStudentID(const unsigned long& studentID);
void printDatabase() const;
void sortBySalary();
void sortByLastName();
void sortByPersonalID();
void sortByStudentID();
void addPerson(personPtr person);

bool addStudent(const std::string& firstName,
const std::string& lastName,
const unsigned long long& personalID,
const Gender& gender,
const std::string& address,
const unsigned long& studentIndex);

bool addEmployee(const std::string& firstName,
const std::string& lastName,
const unsigned long long& personalID,
const Gender& gender,
const std::string& address,
const double& salary);

bool loadFromFile(const std::string filename = dbFilename);
bool saveToFile(const std::string filename = dbFilename);
bool removeByPersonalID(const unsigned long long& personalID);
bool removeByStudentID(const unsigned long& studentID);
bool modifySalary(const unsigned long long& personalID, const double& newSalary);
bool modifyAddress(const unsigned long long& personalID, const std::string& address);
};
21 changes: 21 additions & 0 deletions include/Employee.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "Person.hpp"

class Employee : public Person
{
private:
double salary_;
public:
Employee(const std::string& firstName,
const std::string& lastName,
const unsigned long long& personalID,
const Gender& gender,
const std::string& address,
const double& salary);

double getSalary() const;
void setSalary(const double& salary);
std::string getInfo() const;

};

37 changes: 37 additions & 0 deletions include/Person.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once
#include <iostream>
#include <string>
#include <map>

enum class Gender {female, male};

class Person
{
protected:
std::string firstName_;
std::string lastName_;
unsigned long long personalID_;
Gender gender_;
std::string address_;
std::map<Gender, char> convMap_ {{Gender::female, '0'}, {Gender::male, '1'}};

public:
Person(const std::string& firstName,
const std::string& lastName,
const unsigned long long& personalID,
const Gender& gender,
const std::string& address);


std::string getLastName() const;
unsigned long long getPersonalID() const;
void setAddress(const std::string& newAddress);

friend std::ostream& operator<<(std::ostream& os, const Person* person);
virtual std::string getInfo() const;
virtual double getSalary() const;
virtual unsigned long getStudentIndex() const;
virtual void setSalary(const double& salary);
virtual ~Person() {};
};

10 changes: 10 additions & 0 deletions include/PersonalID.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

namespace ValidatePersonalID
{
bool validatePersonalID(const unsigned long long& personalID);
void test();
}

namespace vpid = ValidatePersonalID;

19 changes: 19 additions & 0 deletions include/Student.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include "Person.hpp"

class Student : public Person
{
private:
unsigned long studentIndex_;

public:
Student(const std::string& firstName,
const std::string& lastName,
const unsigned long long& personalID,
const Gender& gender,
const std::string& address,
const unsigned long& studentIndex);

unsigned long getStudentIndex() const;
std::string getInfo() const;
};
Loading