عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
  #1  
قديم 08-08-2008, 03:30 PM
الصورة الرمزية ^_^

^_^ ^_^ غير متواجد حالياً

أنا ابن جلا وطلاع الثنايا

 
تاريخ التسجيل: Mar 2008
نوع الدراسة: دكتوراه
المستوى: الأول
الجنس: ذكر
المشاركات: 385
Thumbs up برنامج يرسم ... ^_^


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

هذا برنامج بسيط بلغة السي بلس بلس cpp يرسم سيارات وشاحنات
برمجته من زماااان ودحين أعرضه عليكم كبرنامج مفتوح المصدر نقرتين لعرض الصورة في صفحة مستقلة

يعني مع الكود حقه للي يحب يطوره نقرتين لعرض الصورة في صفحة مستقلة


البرنامج في المرفقات

كود:
#include <vector> #include <ccc_win.cpp> using namespace std; // Based class Vehicle class Vehicle { public: Vehicle(); Vehicle(Point p); Point get_position() const; virtual void draw() const; private: Point position; }; Vehicle::Vehicle() { } Vehicle::Vehicle(Point p) { position = p; } / return the vehicle position */ Point Vehicle::get_position() const { return position; } void Vehicle::draw() const { } // Derived class Car class Car : public Vehicle { public: Car(); Car(Point p); virtual void draw() const; }; Car::Car() { } Car::Car(Point p) : Vehicle(p) { } void Car::draw() const { Point p = get_position(); double x = p.get_x(); double y = p.get_y(); cwin << Line(Point(x, y + 2), Point(x, y + 4)); cwin << Line(Point(x, y + 4), Point(x+10,y+4)); cwin << Line(Point(x+10,y + 4), Point(x+10,y+2)); cwin << Line(Point(x+10,y + 2), Point(x, y+2)); cwin << Line(Point(x+3, y + 4), Point(x+3, y+6)); cwin << Line(Point(x+3, y + 6), Point(x+7, y+6)); cwin << Line(Point(x+7, y + 6), Point(x+7, y+4)); cwin << Circle(Point(x+3, y+1), 1); cwin << Circle(Point(x+7, y+1), 1); } class Truck : public Vehicle { public: Truck(); Truck(Point p); virtual void draw() const; }; Truck::Truck() { } Truck::Truck(Point p) : Vehicle(p) { } // Derived class Truck void Truck::draw() const { Point p = get_position(); double x = p.get_x(); double y = p.get_y(); cwin << Line(Point(x, y + 2), Point(x, y + 7)); cwin << Line(Point(x, y + 7), Point(x + 4,y + 7)); cwin << Line(Point(x + 4,y + 7), Point(x + 4,y + 2)); cwin << Line(Point(x + 4,y + 2), Point(x, y + 2)); cwin << Line(Point(x + 4.1, y + 2), Point(x + 4.1, y + 8)); cwin << Line(Point(x + 4.1, y + 8), Point(x + 12, y + 8)); cwin << Line(Point(x + 12, y + 8), Point(x + 12, y + 2)); cwin << Line(Point(x + 12, y + 2), Point(x + 4.1, y + 2)); cwin << Circle(Point(x + 2, y + 1), 1); cwin << Circle(Point(x + 5, y + 1), 1); cwin << Circle(Point(x + 7, y + 1), 1); cwin << Circle(Point(x + 9, y + 1), 1); cwin << Circle(Point(x + 11, y + 1), 1); } // Main program int ccc_win_main() { vector<Vehicle*> v(8); /* This is vector of vehicles */ v[0] = new Car(Point(2,2)); v[1] = new Truck(Point(14,2)); v[2] = new Car(Point(27,2)); v[3] = new Truck(Point(2,12)); v[4] = new Car(Point(15,12)); v[5] = new Car(Point(30,12)); v[6] = new Truck(Point(20,24)); v[7] = new Car(Point(10,40)); cwin.coord(-10,50,50,-10); int i; for (i = 0; i < v.size(); i++) v[i]->draw(); return 0; }
الملفات المرفقة
نوع الملف: zip Drawign Vehicles.zip‏ (170.0 كيلوبايت, المشاهدات 108)
نصائح مهمة : 1 - إفحص الملف المرفق بأي برنامج مضاد للفيروسات
2 - قم بمراسلة الإدارة عن أي مرفق يوجد به فيروس
3 - المنتدى غير مسوؤل عن مايحتويه المرفق من بيانات
رد مع اقتباس