feladat2 fix 1 + feladat7 start
This commit is contained in:
parent
6ca06962d9
commit
3bd4b31b23
18 changed files with 407 additions and 35 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
//Tóth Dániel Mátyás | IFPQYY | v2
|
//Tóth Dániel Mátyás | IFPQYY | v3
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "CppUnitTest.h"
|
#include "CppUnitTest.h"
|
||||||
#include "feladat2.h"
|
#include "feladat2.h"
|
||||||
|
|
@ -151,6 +151,50 @@ namespace UnitTest1
|
||||||
Assert::AreEqual(4, capacity());
|
Assert::AreEqual(4, capacity());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
TEST_METHOD(RegularOperationTest) {
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(6);
|
||||||
|
|
||||||
|
push('a');
|
||||||
|
push('b');
|
||||||
|
push('c');
|
||||||
|
push('d');
|
||||||
|
push('e');
|
||||||
|
push('f');
|
||||||
|
|
||||||
|
Assert::AreEqual(6, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual('a', (char)pop());
|
||||||
|
Assert::AreEqual('b', (char)pop());
|
||||||
|
Assert::AreEqual('c', (char)pop());
|
||||||
|
|
||||||
|
Assert::AreEqual(6, capacity());
|
||||||
|
Assert::AreEqual(3, freespace());
|
||||||
|
|
||||||
|
destroyfifo();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(SpecialCase1) {//stolen straight from the email
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(3);
|
||||||
|
|
||||||
|
push(0);
|
||||||
|
push(1);
|
||||||
|
push(2);
|
||||||
|
|
||||||
|
Assert::AreEqual(3, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual(0, pop());
|
||||||
|
|
||||||
|
Assert::AreEqual(OK, push((char)255));
|
||||||
|
|
||||||
|
Assert::AreEqual(3, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual(1, pop());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>C:\Users\danit\Desktop\cpp\feladat2\feladat2\feladat2;C:\Users\danit\Desktop\cpp\feladat2\feladat2;$(IncludePath)</IncludePath>
|
<ReferencePath>C:\Users\danit\Desktop\2026-27-cpp-homework\feladat2\feladat2;$(ReferencePath)</ReferencePath>
|
||||||
|
<IncludePath>C:\Users\danit\Desktop\2026-27-cpp-homework\feladat2\feladat2;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
|
@ -143,7 +144,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<AdditionalLibraryDirectories>C:\Users\danit\Desktop\cpp\feladat2\feladat2\feladat2\x64\Debug;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>C:\Users\danit\Desktop\2026-27-cpp-homework\feladat2\feladat2\x64\Debug;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>feladat2;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>feladat2;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
@ -182,8 +183,8 @@
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\feladat2\feladat2\feladat2.vcxproj">
|
<ProjectReference Include="..\feladat2\feladat2.vcxproj">
|
||||||
<Project>{c0af2585-3697-4ad9-bd3a-67823343a675}</Project>
|
<Project>{6c528726-81ac-44ca-9c09-f9fde7941386}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
<Platform Name="x64" />
|
<Platform Name="x64" />
|
||||||
<Platform Name="x86" />
|
<Platform Name="x86" />
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<Project Path="feladat2/feladat2/feladat2.vcxproj" Id="c0af2585-3697-4ad9-bd3a-67823343a675" />
|
<Project Path="feladat2/feladat2.vcxproj" />
|
||||||
<Project Path="UnitTest1/UnitTest1.vcxproj" />
|
<Project Path="UnitTest1/UnitTest1.vcxproj" />
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|
|
||||||
BIN
feladat2/feladat2/IFPQYY_feladat2v3.zip
Normal file
BIN
feladat2/feladat2/IFPQYY_feladat2v3.zip
Normal file
Binary file not shown.
200
feladat2/feladat2/UnitTest1.cpp
Normal file
200
feladat2/feladat2/UnitTest1.cpp
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
//Tóth Dániel Mátyás | IFPQYY | v3
|
||||||
|
#include "pch.h"
|
||||||
|
#include "CppUnitTest.h"
|
||||||
|
#include "feladat2.h"
|
||||||
|
|
||||||
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||||
|
|
||||||
|
namespace UnitTest1
|
||||||
|
{
|
||||||
|
TEST_CLASS(UnitTest1)
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//Works weirdly, seems like the test methods are not isolated in themselves in this instance, will need to create and destroy in every
|
||||||
|
//seperate test to guarantee they will work as intended. If only these were in classes instead of being global.....
|
||||||
|
|
||||||
|
TEST_METHOD(CreateTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
Assert::AreEqual(OK, createfifo(10));
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(CreateTest2)
|
||||||
|
{
|
||||||
|
createfifo(10);
|
||||||
|
Assert::AreEqual(NOK, createfifo(10));
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(DestroyTest1)
|
||||||
|
{
|
||||||
|
createfifo(10);
|
||||||
|
Assert::AreEqual(OK, destroyfifo());
|
||||||
|
}
|
||||||
|
TEST_METHOD(DestroyTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
Assert::AreEqual(NOK, destroyfifo());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(PushTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
Assert::AreEqual(OK, push('c'));
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(PopTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
push('c');
|
||||||
|
Assert::AreEqual('c', (char)pop());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(PopTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
Assert::AreEqual(NOK, pop());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(PopTest3)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
push('c');
|
||||||
|
Assert::AreEqual('c', (char)pop());
|
||||||
|
Assert::AreEqual(NOK, pop());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(PeekTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
push('c');
|
||||||
|
Assert::AreEqual('c', (char)peek());
|
||||||
|
Assert::AreEqual('c', (char)peek());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(PeekTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
Assert::AreEqual(NOK, pop());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(FreespaceTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
int s = 5;
|
||||||
|
createfifo(s);
|
||||||
|
for (int i = 0; i < s; i++)
|
||||||
|
{
|
||||||
|
push('t');
|
||||||
|
}
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(FreespaceTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
int s = 5;
|
||||||
|
createfifo(s);
|
||||||
|
for (int i = 0; i < s-1; i++)
|
||||||
|
{
|
||||||
|
push('t');
|
||||||
|
}
|
||||||
|
Assert::AreEqual(1, freespace());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(CapacityTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
int s = 5;
|
||||||
|
createfifo(s);
|
||||||
|
Assert::AreEqual(s, capacity());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(CapacityTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
int s = 5;
|
||||||
|
createfifo(s);
|
||||||
|
push('c');
|
||||||
|
Assert::AreEqual(s, capacity());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(ClearTest1)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(10);
|
||||||
|
push('c');
|
||||||
|
Assert::AreEqual(OK, clearfifo());
|
||||||
|
Assert::AreEqual(NOK, pop());
|
||||||
|
Assert::AreEqual(NOK, peek());
|
||||||
|
destroyfifo();
|
||||||
|
}
|
||||||
|
TEST_METHOD(ClearTest2)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
Assert::AreEqual(NOK, clearfifo());
|
||||||
|
}
|
||||||
|
TEST_METHOD(EnlargeTest)
|
||||||
|
{
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(2); //2
|
||||||
|
push('c'); //1
|
||||||
|
push('a'); //0
|
||||||
|
push('d'); //doubles
|
||||||
|
Assert::AreEqual(4, capacity());
|
||||||
|
|
||||||
|
}
|
||||||
|
TEST_METHOD(RegularOperationTest) {
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(6);
|
||||||
|
|
||||||
|
push('a');
|
||||||
|
push('b');
|
||||||
|
push('c');
|
||||||
|
push('d');
|
||||||
|
push('e');
|
||||||
|
push('f');
|
||||||
|
|
||||||
|
Assert::AreEqual(6, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual('a', (char)pop());
|
||||||
|
Assert::AreEqual('b', (char)pop());
|
||||||
|
Assert::AreEqual('c', (char)pop());
|
||||||
|
|
||||||
|
Assert::AreEqual(6, capacity());
|
||||||
|
Assert::AreEqual(3, freespace());
|
||||||
|
|
||||||
|
destroyfifo();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(SpecialCase1) {//stolen straight from the email
|
||||||
|
destroyfifo();
|
||||||
|
createfifo(3);
|
||||||
|
|
||||||
|
push(0);
|
||||||
|
push(1);
|
||||||
|
push(2);
|
||||||
|
|
||||||
|
Assert::AreEqual(3, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual(0, pop());
|
||||||
|
|
||||||
|
Assert::AreEqual(OK, push((char)255));
|
||||||
|
|
||||||
|
Assert::AreEqual(3, capacity());
|
||||||
|
Assert::AreEqual(0, freespace());
|
||||||
|
|
||||||
|
Assert::AreEqual(1, pop());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//Tóth Dániel Mátyás | IFPQYY | v2
|
//Tóth Dániel Mátyás | IFPQYY | v3
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "feladat2.h"
|
#include "feladat2.h"
|
||||||
|
|
@ -85,6 +85,7 @@ int pop(void) {
|
||||||
}
|
}
|
||||||
int ret = fifo[tail];
|
int ret = fifo[tail];
|
||||||
tail = (tail + 1) % lngt;
|
tail = (tail + 1) % lngt;
|
||||||
|
full = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +106,7 @@ int freespace(void) {
|
||||||
if (full) {
|
if (full) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return lngt - ((head - tail + lngt) % lngt);
|
return (tail - head + lngt) % lngt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int capacity(void) {
|
int capacity(void) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//Tóth Dániel Mátyás | IFPQYY | v2
|
//Tóth Dániel Mátyás | IFPQYY | v3
|
||||||
#pragma once
|
#pragma once
|
||||||
#define OK 0
|
#define OK 0
|
||||||
#define NOK -1
|
#define NOK -1
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,10 @@
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\..\..\Downloads\feladat2\feladat2.cpp" />
|
|
||||||
<ClCompile Include="..\..\..\..\Downloads\feladat2\main.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\..\..\Downloads\feladat2\feladat2.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>18.0</VCProjectVersion>
|
<VCProjectVersion>18.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{a2f27c2b-a860-44db-b1ea-4fa4467bd633}</ProjectGuid>
|
<ProjectGuid>{6c528726-81ac-44ca-9c09-f9fde7941386}</ProjectGuid>
|
||||||
<RootNamespace>feladat2</RootNamespace>
|
<RootNamespace>feladat2</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -145,6 +138,13 @@
|
||||||
<EnableSegmentHeap>true</EnableSegmentHeap>
|
<EnableSegmentHeap>true</EnableSegmentHeap>
|
||||||
</Manifest>
|
</Manifest>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="feladat2.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="feladat2.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,16 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\..\Downloads\feladat2\feladat2.cpp">
|
<ClInclude Include="feladat2.h">
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\..\..\Downloads\feladat2\main.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\..\..\Downloads\feladat2\feladat2.h">
|
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="feladat2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//Tóth Dániel Mátyás | IFPQYY | v2
|
//Tóth Dániel Mátyás | IFPQYY | v3
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "feladat2.h"
|
#include "feladat2.h"
|
||||||
|
|
||||||
|
|
|
||||||
7
feladat7/feladat7.slnx
Normal file
7
feladat7/feladat7.slnx
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<Solution>
|
||||||
|
<Configurations>
|
||||||
|
<Platform Name="x64" />
|
||||||
|
<Platform Name="x86" />
|
||||||
|
</Configurations>
|
||||||
|
<Project Path="feladat7/feladat7.vcxproj" Id="162a458c-6f90-431f-8425-2fc866a1673c" />
|
||||||
|
</Solution>
|
||||||
26
feladat7/feladat7/cphoneiterfiltered.cpp
Normal file
26
feladat7/feladat7/cphoneiterfiltered.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||||
|
#include "cphoneiterfiltered.h"
|
||||||
|
|
||||||
|
|
||||||
|
CPhoneIterFiltered::CPhoneIterFiltered(const CPhoneList& m, const char* group, unsigned flag) {
|
||||||
|
m_cpList = m;
|
||||||
|
m_iCurrIndex = 0;
|
||||||
|
m_iCount = 0;
|
||||||
|
//m_piNameIndex =
|
||||||
|
}
|
||||||
|
CPhoneIterFiltered::~CPhoneIterFiltered() {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::begin() {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::prev() {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::next() {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::end() {
|
||||||
|
}
|
||||||
|
int CPhoneIterFiltered::size() const {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::search(const char* key) {
|
||||||
|
}
|
||||||
|
const Record* CPhoneIterFiltered::operator++() {
|
||||||
|
}
|
||||||
23
feladat7/feladat7/cphoneiterfiltered.h
Normal file
23
feladat7/feladat7/cphoneiterfiltered.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||||
|
#pragma once
|
||||||
|
#include "cphonelist.h"
|
||||||
|
class CPhoneIterFiltered
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPhoneIterFiltered(const CPhoneList& m, const char* group, unsigned flag = 1);
|
||||||
|
~CPhoneIterFiltered();
|
||||||
|
const Record* begin();
|
||||||
|
const Record* prev();
|
||||||
|
const Record* next();
|
||||||
|
const Record* end();
|
||||||
|
int size() const;
|
||||||
|
const Record* search(const char* key);
|
||||||
|
const Record * operator++();
|
||||||
|
CPhoneIterFiltered(const CPhoneIterFiltered&) = delete;
|
||||||
|
CPhoneIterFiltered& operator=(const CPhoneIterFiltered&) = delete;
|
||||||
|
private:
|
||||||
|
const CPhoneList* const m_cpList;
|
||||||
|
int m_iCurrIndex;
|
||||||
|
int m_iCount;
|
||||||
|
int* m_piNameIndex;
|
||||||
|
};
|
||||||
30
feladat7/feladat7/cphonelist.cpp
Normal file
30
feladat7/feladat7/cphonelist.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||||
|
#include "cphonelist.h"
|
||||||
|
|
||||||
|
CPhoneList::CPhoneList() {
|
||||||
|
m_iFirstEmpty = 0;
|
||||||
|
}
|
||||||
|
int CPhoneList::append(const Record& newrec) {
|
||||||
|
if (m_iFirstEmpty >= MAXLENGTH)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
m_rArray[m_iFirstEmpty] = (Record&&)newrec;
|
||||||
|
m_iFirstEmpty++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void CPhoneList::displayname(unsigned flag = 0, const char* group = nullptr) {
|
||||||
|
}
|
||||||
|
int CPhoneList::GetFirstEmpty() {
|
||||||
|
return m_iFirstEmpty;
|
||||||
|
}
|
||||||
|
bool CPhoneList::saveToFile(const char* filename) {
|
||||||
|
}
|
||||||
|
bool CPhoneList::loadFromFile(const char* filename) {
|
||||||
|
}
|
||||||
|
Record& CPhoneList::operator[](size_t nIndex) {
|
||||||
|
return m_rArray[nIndex];
|
||||||
|
}
|
||||||
|
std::ostream& operator << (std::ostream& os, Record& r) {
|
||||||
|
os << std::endl << r.name << ';' << r.number << ";" << r.group;
|
||||||
|
}
|
||||||
29
feladat7/feladat7/cphonelist.h
Normal file
29
feladat7/feladat7/cphonelist.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||||
|
#pragma once
|
||||||
|
#include <ostream>
|
||||||
|
#define MAXLENGTH 10
|
||||||
|
#define MAXNAME 32
|
||||||
|
#define MAXNUMBER 16
|
||||||
|
#define MAXGROUP 12
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
char name[MAXNAME + 1];
|
||||||
|
char number[MAXNUMBER + 1];
|
||||||
|
char group[MAXGROUP + 1];
|
||||||
|
};
|
||||||
|
class CPhoneList
|
||||||
|
{
|
||||||
|
friend class CPhoneIterFiltered;
|
||||||
|
public:
|
||||||
|
CPhoneList();
|
||||||
|
int append(const Record& newrec);
|
||||||
|
void displayname(unsigned flag = 0, const char* group = nullptr);
|
||||||
|
int GetFirstEmpty();
|
||||||
|
bool saveToFile(const char* filename);
|
||||||
|
bool loadFromFile(const char* filename);
|
||||||
|
Record& operator[](size_t nIndex);
|
||||||
|
private:
|
||||||
|
Record m_rArray[MAXLENGTH];
|
||||||
|
int m_iFirstEmpty;
|
||||||
|
};
|
||||||
|
std::ostream& operator << (std::ostream& os, Record& r);
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>18.0</VCProjectVersion>
|
<VCProjectVersion>18.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{c0af2585-3697-4ad9-bd3a-67823343a675}</ProjectGuid>
|
<ProjectGuid>{162a458c-6f90-431f-8425-2fc866a1673c}</ProjectGuid>
|
||||||
<RootNamespace>feladat2</RootNamespace>
|
<RootNamespace>feladat7</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
|
@ -139,11 +139,13 @@
|
||||||
</Manifest>
|
</Manifest>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\feladat2.cpp" />
|
<ClCompile Include="cphoneiterfiltered.cpp" />
|
||||||
<ClCompile Include="..\main.cpp" />
|
<ClCompile Include="cphonelist.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\feladat2.h" />
|
<ClInclude Include="cphoneiterfiltered.h" />
|
||||||
|
<ClInclude Include="cphonelist.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
@ -15,15 +15,21 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\feladat2.cpp">
|
<ClCompile Include="cphonelist.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="cphoneiterfiltered.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\feladat2.h">
|
<ClInclude Include="cphonelist.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="cphoneiterfiltered.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
3
feladat7/feladat7/main.cpp
Normal file
3
feladat7/feladat7/main.cpp
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||||
|
|
||||||
|
#include "cphoneiterfiltered.h"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue