lesson 3, exercise 1
This commit is contained in:
parent
c451149748
commit
407e117689
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
main.o: ../main.cpp ../exercise_1.hpp ../exercise_2.hpp ../exercise_3.hpp \
|
||||||
|
../exercise_4.hpp
|
||||||
|
../exercise_1.hpp:
|
||||||
|
../exercise_2.hpp:
|
||||||
|
../exercise_3.hpp:
|
||||||
|
../exercise_4.hpp:
|
Binary file not shown.
|
@ -0,0 +1,57 @@
|
||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
-include ../makefile.init
|
||||||
|
|
||||||
|
RM := rm -rf
|
||||||
|
|
||||||
|
# All of the sources participating in the build are defined here
|
||||||
|
-include sources.mk
|
||||||
|
-include subdir.mk
|
||||||
|
-include objects.mk
|
||||||
|
|
||||||
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
|
ifneq ($(strip $(CC_DEPS)),)
|
||||||
|
-include $(CC_DEPS)
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(C++_DEPS)),)
|
||||||
|
-include $(C++_DEPS)
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(C_UPPER_DEPS)),)
|
||||||
|
-include $(C_UPPER_DEPS)
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(CXX_DEPS)),)
|
||||||
|
-include $(CXX_DEPS)
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(CPP_DEPS)),)
|
||||||
|
-include $(CPP_DEPS)
|
||||||
|
endif
|
||||||
|
ifneq ($(strip $(C_DEPS)),)
|
||||||
|
-include $(C_DEPS)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
-include ../makefile.defs
|
||||||
|
|
||||||
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
|
|
||||||
|
# All Target
|
||||||
|
all: lesson_3
|
||||||
|
|
||||||
|
# Tool invocations
|
||||||
|
lesson_3: $(OBJS) $(USER_OBJS)
|
||||||
|
@echo 'Building target: $@'
|
||||||
|
@echo 'Invoking: GCC C++ Linker'
|
||||||
|
g++ -o "lesson_3" $(OBJS) $(USER_OBJS) $(LIBS)
|
||||||
|
@echo 'Finished building target: $@'
|
||||||
|
@echo ' '
|
||||||
|
|
||||||
|
# Other Targets
|
||||||
|
clean:
|
||||||
|
-$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) lesson_3
|
||||||
|
-@echo ' '
|
||||||
|
|
||||||
|
.PHONY: all clean dependents
|
||||||
|
|
||||||
|
-include ../makefile.targets
|
|
@ -0,0 +1,8 @@
|
||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
USER_OBJS :=
|
||||||
|
|
||||||
|
LIBS :=
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
C_UPPER_SRCS :=
|
||||||
|
CXX_SRCS :=
|
||||||
|
C++_SRCS :=
|
||||||
|
OBJ_SRCS :=
|
||||||
|
CC_SRCS :=
|
||||||
|
ASM_SRCS :=
|
||||||
|
CPP_SRCS :=
|
||||||
|
C_SRCS :=
|
||||||
|
O_SRCS :=
|
||||||
|
S_UPPER_SRCS :=
|
||||||
|
CC_DEPS :=
|
||||||
|
C++_DEPS :=
|
||||||
|
EXECUTABLES :=
|
||||||
|
C_UPPER_DEPS :=
|
||||||
|
CXX_DEPS :=
|
||||||
|
OBJS :=
|
||||||
|
CPP_DEPS :=
|
||||||
|
C_DEPS :=
|
||||||
|
|
||||||
|
# Every subdirectory with source files must be described here
|
||||||
|
SUBDIRS := \
|
||||||
|
. \
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
|
CPP_SRCS += \
|
||||||
|
../main.cpp
|
||||||
|
|
||||||
|
OBJS += \
|
||||||
|
./main.o
|
||||||
|
|
||||||
|
CPP_DEPS += \
|
||||||
|
./main.d
|
||||||
|
|
||||||
|
|
||||||
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
|
%.o: ../%.cpp
|
||||||
|
@echo 'Building file: $<'
|
||||||
|
@echo 'Invoking: GCC C++ Compiler'
|
||||||
|
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
|
||||||
|
@echo 'Finished building: $<'
|
||||||
|
@echo ' '
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* Для расчет площади фигур квадрат/ромб/прямоугольник/параллелограмм
|
||||||
|
* справедлива будет одна общая формула - произведение основания на высоту
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXERCISE_1_HPP_
|
||||||
|
#define EXERCISE_1_HPP_
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define PI 3.14159265358979323846
|
||||||
|
|
||||||
|
float getRadian(float degree)
|
||||||
|
{
|
||||||
|
return PI / 180 * degree;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Figure
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual float area() = 0;
|
||||||
|
virtual ~Figure() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Parallelogram : public Figure
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
float m_side_a;
|
||||||
|
float m_side_b;
|
||||||
|
float m_height;
|
||||||
|
protected:
|
||||||
|
float getSideA() const
|
||||||
|
{
|
||||||
|
return m_side_a;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getSideB() const
|
||||||
|
{
|
||||||
|
return m_side_b;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
Parallelogram(float side_a, float height, float side_b = 0.0)
|
||||||
|
: m_side_a(side_a), m_side_b(side_b), m_height(height) { }
|
||||||
|
|
||||||
|
float area()
|
||||||
|
{
|
||||||
|
float area = m_side_a * m_height;
|
||||||
|
|
||||||
|
std::cout << "Площадь параллелограмма равна " << area << std::endl;
|
||||||
|
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Circle : public Figure
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class Rectangle : public Parallelogram
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Rectangle(float side_a, float side_b)
|
||||||
|
: Parallelogram(side_a, side_b, side_b) { }
|
||||||
|
|
||||||
|
float area()
|
||||||
|
{
|
||||||
|
float area = getSideA() * getSideB();
|
||||||
|
|
||||||
|
std::cout << "Площадь прямоугольника равна " << area << std::endl;
|
||||||
|
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Square : public Parallelogram
|
||||||
|
{
|
||||||
|
Square(float side_a, float side_b)
|
||||||
|
: Parallelogram(side_a, side_b, side_b) { }
|
||||||
|
|
||||||
|
float area()
|
||||||
|
{
|
||||||
|
float area = getSideA() * getSideB();
|
||||||
|
|
||||||
|
std::cout << "Площадь квадрата равна " << area << std::endl;
|
||||||
|
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Rhombus : public Parallelogram
|
||||||
|
{
|
||||||
|
Rhombus(float side_a, float side_b)
|
||||||
|
: Parallelogram(side_a, side_b, side_b) { }
|
||||||
|
|
||||||
|
float area()
|
||||||
|
{
|
||||||
|
float area = getSideA() * getSideB();
|
||||||
|
|
||||||
|
std::cout << "Площадь ромба равна " << area << std::endl;
|
||||||
|
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef EXERCISE_2_HPP_
|
||||||
|
#define EXERCISE_2_HPP_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef EXERCISE_3_HPP_
|
||||||
|
#define EXERCISE_3_HPP_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef EXERCISE_4_HPP_
|
||||||
|
#define EXERCISE_4_HPP_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include "exercise_1.hpp"
|
||||||
|
#include "exercise_2.hpp"
|
||||||
|
#include "exercise_3.hpp"
|
||||||
|
#include "exercise_4.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue