المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : كود ++c مساعده ,


~ فـَـنـَـنْ ~
02-May-2008, 03:11 AM
..

السلام عليكم ,

ناس تسمع بـ الذوق ! أول موضوع و طلبات :as7: ..

شسمه .. فاتتني المحاضرة الأخيره , فما فهمت شـ المطلوب :thumbdown: ..
و لا كيف أنفذ هـ اللي مافهمته ,

عندي هذي الأكواد :


Operations.h



#ifndef Operations_H_


#define Operations_H_


class Operations
{
private :
int Num;




public :
Operations (int num);




void setNum (int n );



int getNum ();



int Factorial();



int Validate(int num);



void Fraction();



int val_choice (int );



};
#endif /*Operations_H_*/







Operations.cpp


#include <iostream.h>




#include <iomanip.h>

#include "Operations.h"




Operations:: Operations (int num)
{
setNum (num );
}




void Operations:: setNum (int n )
{
Num = Validate(n);
}




int Operations:: getNum ()
{
return Num;
}




int Operations:: Factorial()
{
int j , fact;
fact = 1;




{
for ( j = 0; j <= getNum ();j ++ )
{




if ( j == 0 )
fact = 1;




else
fact *= j;
}
}




return fact;
}





int Operations:: Validate(int num)
{
while ( num < 0 )
{
cout << " please ,, enter the number again and remember that it must be correct positive number.";
cin >> num;
}




return num;
}





void Operations:: Fraction()
{
int i;
double number , j;
for ( i = 1; i <= Num; i ++ )
{
cout<< "\n" << i << "\n ";
number = 0;
for ( j = .1; j <=.9; j +=.1 )
{
number =i + j;
cout << number << " , ";
}




}



}




int Operations:: val_choice (int m)
{
while ( m != 1 && m!=2 && m!=-1 )
{
cout << " \n please ,, enter the number again and remember that it must be correct positive number.";
cin >> m;
}




return m;
}







http://www.fatayat.net/fm/style_emoticons/default/happy.gif.cpp


#include <iostream.h>




#include <iomanip.h>

#include "Operations.h"



int main ()
{
Operations Oper (4);
int n , m;




do
{
cout << "\n please , enter 1 to enter Fraction Or 2 to Fraction Or -1 to finish ";
cin >> m;




m = Oper.val_choice (m);




switch (m )
{
case 1 : cout << " \n the Factorial for " << n << "is " << setprecision(2) << fixed << Oper.Factorial( );;
break;
case 2 : Oper.Fraction() ;




}
}




while ( m!= -1);




return 0;
}








وهذا المطلوب /



Class Operations:



Convert val_choice(int) to global function instead of member function of Operations class, and pass the argument by reference and make your changes that you need.
Add new global function called Menu() that print of the previous choices (i.e.1: Print factorial, 2: Print fraction, -1: exit), read user choice and validate it by calling function val_choice(int)
:az9:




..




تساعدوني ؟



و لاّ حيل الله أقوى ..




الله يجزاكم خير على كل حال :f:




.