Compare commits
No commits in common. "lesson_1" and "master" have entirely different histories.
|
@ -1,21 +0,0 @@
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
class Power
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
float a = 0;
|
|
||||||
float b = 0;
|
|
||||||
public:
|
|
||||||
Power() {}
|
|
||||||
|
|
||||||
void set(float num_a, float num_b)
|
|
||||||
{
|
|
||||||
a = num_a;
|
|
||||||
b = num_b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float calculate()
|
|
||||||
{
|
|
||||||
return pow(a, b);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,23 +0,0 @@
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class RGBA
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::uint8_t m_red;
|
|
||||||
std::uint8_t m_green;
|
|
||||||
std::uint8_t m_blue;
|
|
||||||
std::uint8_t m_alpha;
|
|
||||||
public:
|
|
||||||
RGBA(std::uint8_t red = 0, std::uint8_t green = 0, std::uint8_t blue = 0, std::uint8_t alpha = 255) :
|
|
||||||
m_red(red), m_green(green), m_blue(blue), m_alpha(alpha) {}
|
|
||||||
|
|
||||||
void print()
|
|
||||||
{
|
|
||||||
std::cout << "r=" << static_cast<int>(m_red) <<
|
|
||||||
" g=" << static_cast<int>(m_green) <<
|
|
||||||
" b=" << static_cast<int>(m_blue) <<
|
|
||||||
" a=" << static_cast<int>(m_alpha) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,44 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Stack
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int array[10];
|
|
||||||
int length = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Stack() {}
|
|
||||||
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
while (length)
|
|
||||||
array[length--] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool push(int num)
|
|
||||||
{
|
|
||||||
if (length > 9)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
array[length++] = num;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pop()
|
|
||||||
{
|
|
||||||
if (length)
|
|
||||||
return array[length--];
|
|
||||||
else
|
|
||||||
std::cout << "Stack is empty!" << std::endl;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void print()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < length; i++)
|
|
||||||
std::cout << array[i] << ' ';
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,42 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include "exercise_1.hpp"
|
|
||||||
#include "exercise_2.hpp"
|
|
||||||
#include "exercise_3.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Exercise 1
|
|
||||||
Power Num;
|
|
||||||
|
|
||||||
Num.set(2.0, 3.0);
|
|
||||||
cout << Num.calculate() << endl;
|
|
||||||
|
|
||||||
// Exercise 2
|
|
||||||
|
|
||||||
RGBA Color1;
|
|
||||||
Color1.print();
|
|
||||||
RGBA Color2(100, 123, 210, 13);
|
|
||||||
Color2.print();
|
|
||||||
|
|
||||||
// Exercise 3
|
|
||||||
|
|
||||||
Stack stack;
|
|
||||||
stack.reset();
|
|
||||||
stack.print();
|
|
||||||
|
|
||||||
stack.push(3);
|
|
||||||
stack.push(7);
|
|
||||||
stack.push(5);
|
|
||||||
stack.print();
|
|
||||||
|
|
||||||
stack.pop();
|
|
||||||
stack.print();
|
|
||||||
|
|
||||||
stack.pop();
|
|
||||||
stack.pop();
|
|
||||||
stack.print();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue