• 0
  • مالي خلق
  • أتهاوش
  • متضايق
  • مريض
  • مستانس
  • مستغرب
  • مشتط
  • أسولف
  • مغرم
  • معصب
  • منحرج
  • آكل
  • ابكي
  • ارقص
  • اصلي
  • استهبل
  • اضحك
  • اضحك  2
  • تعجبني
  • بضبطلك
  • رايق
  • زعلان
  • عبقري
  • نايم
  • طبيعي
  • كشخة
  • النتائج 1 إلى 3 من 3

    الموضوع: مكتبه مصغره في السي

    1. #1
      التسجيل
      21-01-2004
      المشاركات
      16
      المواضيع
      2
      شكر / اعجاب مشاركة

      مكتبه مصغره في السي

      السلام عليكم ورحمة الله وبركاته

      عندي عمل مكتبه بلغة السي المطلوب فيها menu اضافة كتاب حذف كتاب البحث عن كتاب
      وطبعا البحث كان يحتاج مني array of objects للاسف ما عرفت استخدمه شوفولي هالبرنامج والله تعبني والي يعافيكم لا تبخلون علينا
      #include<iostream>
      #include<string>
      using namespace std;
      class Book{
      private:
      string Author;
      string Publisher;
      string Country;
      string ISBN;
      public:
      Book(void){} //default constructor
      Book(string auther,string publisher,string country,string isbn)
      { Author=auther;
      Publisher=publisher;
      Country=country;
      ISBN=isbn;
      } // initialization constructor

      ///////////////////////////
      void DeleteBook(Book& b)const;
      ;bool isValid(string isbn);
      string return_ISBN(){return ISBN;}
      string return_country(){return Country;}
      string return_author(){return Author;}
      string return_publisher(){return Publisher;}
      };//end of class
      void Book:eleteBook(Book& b)const//func deletebook
      {
      b.return_author()=" ";
      b.return_country()=" ";
      b.return_ISBN()=" ";
      b.return_publisher()=" ";
      }//end deleteBook
      bool Book::isValid(string isbn)//func isvalid
      {string no;
      if(isbn.empty())
      {cout<<"The ISBN is empty ,enter ISBN :";
      cin>>no;
      isbn=no;}//end if
      int sum=0;
      sum+=(int)isbn[0];
      for(int i=2;i<5;i++)
      sum+=(int)isbn[i];
      for(int c=6;c<11;c++)
      sum+=(int)isbn[c];
      if(isbn[13]=='X' || isbn[13]=='x')
      sum+=10;
      if(sum%11==0)
      return true;
      else
      return false;
      }//end isValid*/

      وهذا الكلاس تبعه

    2. #2
      التسجيل
      21-01-2004
      المشاركات
      16
      المواضيع
      2
      شكر / اعجاب مشاركة

      مشاركة: مكتبه مصغره في السي

      و هذا main
      #include <iostream>
      #include <string>
      #include <fstream>
      #include "MyLibrary.h"
      using std:fstream;
      using std::ifstream;
      #include <iomanip>
      using std::setw;
      using std::setprecision;
      #include <cstdlib>
      using namespace std;

      int isbnNo,option;
      string author, publisher,country,isbn,A;
      void main(){
      Book MyBook();
      do{
      // get user's option
      int option;
      // display options
      cout << "\nEnter your option" << endl
      << " 1 - Add new book " << endl
      << " 2 - Delete book" << endl
      << " 3 - List of books" << endl;
      cin >> option;
      // process user's option
      switch ( option ) {
      case 1:
      {
      // ifstream constructor opens the file
      ofstream outf( "MyLibrary.dat", ios::app );
      // exit program if ifstream could not open file
      if ( !outf )
      {
      cerr << "File could not be opened" << endl;
      exit( 1 );
      } // end if

      cout<<"enter the author name ,publisher name,country,ISBN"<<endl;
      //<<"enter ctrl+z then enter to end .\n";
      // display each record in file
      cin >>author>> publisher >> country >>isbn;
      outf<< author <<" "<< publisher<<" "
      << country <<" "<< isbn << endl;

      outf.close(); // ifstream destructor closes the file
      Book MyBook(author,publisher,country,isbn);
      };//end case1
      break;
      case 2:
      {cout <<"\nEnter the ISBN of the book you want to delete \n";
      cin>>isbnNo;

      };
      break;
      case 3:
      cout<<"\nThis is a list of books in this library:\n";
      cout<<"author name publisher name country ISBN \n";
      {// ifstream constructor opens the file
      ifstream inf( "MyLibrary.dat", ios::in );
      // exit program if ifstream could not open file
      if ( !inf )
      {
      cerr << "File could not be opened" << endl;
      exit( 1 );
      } // end if;


      do{
      inf >> author >> publisher >> country >> isbn;
      cout << /*left << setw( 15 ) <<" "<<*/ author /*<< setw( 20 ) <<<<" " */
      <<publisher/*<< setw( 15 ) <<<<" "*/<<country /*<< right <<setw( 10 ) <<*/
      /*<< " " */<< isbn << endl;
      }//end do
      // display file contents (until eof)
      while ( !inf.eof() );
      inf.close();}
      break;
      default: cout<< "you did not chioce \n";
      break ;
      } // end switch
      cout<<"do you want to enter your option agian: enter yes or no\n";
      cin>>A;

      }//end do
      while(A=="yes" || A=="YES");

      }//end main

      زالي يقدر يساعدني لا يتاخر

    3. #3
      التسجيل
      04-09-2003
      المشاركات
      300
      المواضيع
      4
      شكر / اعجاب مشاركة

      مشاركة: مكتبه مصغره في السي

      attach the source file with ur post...it is much better, cleaner, well formatted...ect
      i found a job...

    ضوابط المشاركة

    • لا تستطيع إضافة مواضيع جديدة
    • لا تستطيع الرد على المواضيع
    • لا تستطيع إرفاق ملفات
    • لا تستطيع تعديل مشاركاتك
    •