Dmitry 5 years ago
parent
commit
4b11fc92bb
4 changed files with 99 additions and 10 deletions
  1. 3 1
      main.cpp
  2. 53 9
      sCPU.cpp
  3. 37 0
      sStack.cpp
  4. 6 0
      sStack.h

+ 3 - 1
main.cpp

@@ -100,7 +100,9 @@ int main () {
 
 return 0;
 }
-
+/*!
+	Gide to comand
+ */
 void abstract () {
 	cout << "Hellow ! \n"
 			 << "Comand Enter like \n"

+ 53 - 9
sCPU.cpp

@@ -16,6 +16,10 @@ using std::endl;
 
 
 //=======================================
+/*!
+	Constructor of CPU stuct
+	\param cpu1, stack pointers to CPU and stack
+ */
 void cpu_constructor (sCPU *cpu1, sStack *stack) {
 	
 	cpu1->st = stack;
@@ -23,6 +27,11 @@ void cpu_constructor (sCPU *cpu1, sStack *stack) {
 }
 
 //========================================
+/*!
+	Check CPU 
+	\param cpu1 pointers to CPU
+	\return bool parameter true if all OK
+ */
 bool sCPU_Ok (sCPU *cpu1) {
 	
 	if (!sStack_Ok (cpu1->st)) {
@@ -33,6 +42,11 @@ bool sCPU_Ok (sCPU *cpu1) {
 }
 
 //========================================
+/*!
+	calculate the sine of last element in stack
+	\param cpu pointers to CPU
+	\return rezalt sine of number
+ */
 double sCPU_sinus (sCPU *cpu) {
 
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -55,6 +69,11 @@ double sCPU_sinus (sCPU *cpu) {
 }
 
 //=======================================
+/*!
+	calculate the cosine of last element in stack
+	\param cpu pointers to CPU
+	\return rezalt cosine of number
+ */
 double sCPU_cosine (sCPU *cpu) {
 
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -78,6 +97,11 @@ double sCPU_cosine (sCPU *cpu) {
 }
 
 //=======================================
+/*!
+	calculate the addition of the two last elements in the stack
+	\param cpu pointers to CPU
+	\return summer of tow nummbers
+ */
 double sCPU_addition (sCPU *cpu) {
 	
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -103,6 +127,11 @@ double sCPU_addition (sCPU *cpu) {
 }
 
 //=======================================
+/*!
+	calculate the subtraction of the two last elements in the stack
+	\param cpu pointers to CPU
+	\return subtraction of tow nummbers
+ */
 double sCPU_subtraction (sCPU *cpu) {
 
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -129,6 +158,11 @@ double sCPU_subtraction (sCPU *cpu) {
 }
 
 //=======================================
+/*!
+	calculate the multiplication of the two last elements in the stack
+	\param cpu pointers to CPU
+	\return multiplication of tow nummbers
+ */
 double sCPU_multiplication (sCPU *cpu) {
 		
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -155,22 +189,22 @@ double sCPU_multiplication (sCPU *cpu) {
 }
 
 //======================================
+/*!
+	Show the CPU and stack
+ \param cpu pointers to CPU
+ */
 void 	 sCPU_show (const sCPU *cpu) {
 		
 	sStack_show (cpu->st);
 
 }
 
-//=====================================
-bool sCPU_Ok (const sCPU *cpu) {
-		
-	if (!sStack_Ok (cpu->st)) {
-			return true;
-	} 
-	return false;
-}
-
 //=======================================
+/*!
+	calculate sine in  degrees
+	\param  _number parametet of sine
+	\return rezalt of sine 
+ */
 double my_sinus (double _number) {
 	
 	return sin (_number*M_PI/180);
@@ -178,6 +212,11 @@ double my_sinus (double _number) {
 }
 
 //=======================================
+/*!
+	calculate cosine in  degrees
+	\param parametet of cosine
+	\return rezalt of cosine 
+ */
 double my_cosine (double _number) {
 
 	return cos (_number*M_PI/180);
@@ -185,6 +224,11 @@ double my_cosine (double _number) {
 }
 
 //======================================
+/*!
+	 treats errors
+	\param number of error
+	\return bool parameter 
+ */
 bool 	processing_error (const double namb_0f_error) {
 	
 	if (namb_0f_error == not_enouth_number) {

+ 37 - 0
sStack.cpp

@@ -18,6 +18,10 @@ using std::cout;
 using std::endl;
 
 //========================================
+/*!
+	Constructor of  stack struct
+	\param stack pointers 
+ */
 void Stack_constructor (sStack *stack) {
 	 
 	stack->memory_guard_first = guard_first;
@@ -34,6 +38,10 @@ void Stack_constructor (sStack *stack) {
 }
 
 //========================================
+/*!
+	Destructor of  stack struct
+	\param stack pointers 
+ */
 void Stack_destructoin (sStack *stack) {
 
 	stack->top = -100;
@@ -46,6 +54,10 @@ void Stack_destructoin (sStack *stack) {
 }
 
 //========================================
+/*!
+	The function is showing  stack 
+	\param stack pointers 
+ */
 void sStack_show (const sStack *stack) {
 
 	cout << "top = " << stack->top << endl;
@@ -61,6 +73,12 @@ void sStack_show (const sStack *stack) {
 }
 
 //========================================
+/*!
+	The function is showing  the last element of stack and 
+		do not remove it
+	\param stack pointers 
+	\return the value of the last element in stack 
+ */
 double sStack_show_last_element (const sStack *stack) {
 	
 	if (sStack_size (stack) < 1 ) {
@@ -78,6 +96,10 @@ double sStack_show_last_element (const sStack *stack) {
 }
 
 //========================================
+/*!
+	THe function is showing the size of stack
+	\param stack pointers 
+ */
 int  sStack_size (const sStack *stack) {
 
 	//cout << "Stack size: " << stack->top << endl; 
@@ -90,6 +112,11 @@ int  sStack_size (const sStack *stack) {
 }
 
 //========================================
+/*!
+	The function add one more number in stack
+	\param stack pointers 
+	\param vell the new number
+ */
 void sStack_Push (sStack *stack, double vell) {
 
 #ifdef USE_SUPER_PUPER_GUARDS	
@@ -114,6 +141,11 @@ void sStack_Push (sStack *stack, double vell) {
 }
 
 //========================================
+/*!
+	The function return the last element in stack
+	\param stack pointers 
+	\return the last element in stack 
+ */
 double sStack_Pop 	(sStack *stack) {
 	
 	double last_element = stack->data [(stack->top) - 1];
@@ -129,6 +161,11 @@ double sStack_Pop 	(sStack *stack) {
 }
 
 //========================================
+/*!
+	The function Check stack
+	\param stack pointers 
+	\return bool parameter  true io all  OK 
+ */
 bool sStack_Ok (const sStack *stack) {
 	
 	if ((stack->top < 0) || (stack->top > stack->MAX_STACK_SIZE)) {

+ 6 - 0
sStack.h

@@ -5,6 +5,12 @@
 
 
 // --------------------------
+/*!
+	\brief Stack struct 
+	
+	it has constructor, distruction, show, Ok,
+	pop, push and other function
+ */
 struct sStack {
 	
 	static unsigned	const int MAX_STACK_SIZE = 2;