الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب تصحيح

بدأه درر الكون في 16 مايو 2009 · 11 رد · 927 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

اش الغلط في هذا الكود

#include"waiting_reservation.h"

waiting_reservation::waiting_reservation(string name,long bb,string passport,bool 1,int x):reservation( name ,bb,passport,1)<<يطلع هنا خطا

{

turn_list=x;<<وكمان هنا

}

int getturn_list(){

return turn_list;<<وكمان هنا

}

void setturn_list(int x){

turn_list=x;

}

int move_list()

{

if( turn_list>1)<<وكمان هنا

turn_list--;

return turn_list;

else<< هنا

return turn_list;

}

void printDetails(){

reservation::printDetails() ;>>وكمان هنا

cout<<"turn_list:"<<getturn_list;

}

مع العلم بأن جميع الكلاسات التي تسبقها إن شاء الله صحيحة مية بالمية

والاستاذة قيمتني علية وقالت صحيح لكن انا لما سويت حفظ طلعت هذي الاخطاء

ياليت تفيدوني اش السبب

وكمان هذا الكلاس

////////////////////////////////////////////////

#include"reservation.h"

#include"Date.h"

#include"ok_reservation.h"

ok_reservation::ok_reservation(string m ,long v,string g,bool 1,int s,int n,int m):reservation( m ,v,g,1),Date(int d,int m, int y)>> هنا

{

ticket_bought=false;

}

void setticket_bought(bool ){

setticket_bought=true;<< هنا

}

void ok_reservation::printDetails(){

reservation::printDetails() ;

cout<<"setticket_bought:"<<setticket_bought;<< هنا

}

وشاكرة لكم

#2
اقتباس
السلام عليكــم ورحمـة الله وبركاتــه ،،

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

اقتباس
waiting_reservation::waiting_reservation(string name,long bb,string passport,bool 1,int x):reservation( name ,bb,passport,1)

استخدمتى دالة البناء للكلاس reservation دون اسنادها لكائن موجود فى الكلاس

waiting_reservation

اقتباس
turn_list=x;

هل انتى متأكده من وجود العضو turn_list

اقتباس
reservation::printDetails() ;

استخدمى دالة الطباعه للكائن من النوع reservation

والموجود فى الكلاس waiting_reservation

ولا تستخدمى داله الطباعه الموجود فى الكلاس نفسه

اقتباس
ok_reservation::ok_reservation(string m ,long v,string g,bool 1,int s,int n,int m):reservation( m ,v,g,1),Date(int d,int m, int y)

{

ticket_bought=false;

}

نفس المشكله الأولى

اقتباس
void setticket_bought(bool ){

setticket_bought=true;<< هنا

}

هناك خطأ فى اسم المتغير

والله أعلم

سلام

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#3
اقتباس
استخدمتى دالة البناء للكلاس reservation دون اسنادها لكائن موجود فى الكلاس

waiting_reservation

معليش توضح اكثر ماني فاهمتك

اقتباس
هل انتى متأكده من وجود العضو turn_list

اي نعم متاكده ومعرفتها فيprivate

ومشكور اخوي الله يجزاك الجنه

#4

السلام عليكم

وكمان هناك خطأ فى الداله الأولى bool 1

كنت اقصد انكى فى الكلاس wiating أعلنتى عن كائن من النوع reservation

ولكن فى دالة البناء ( للكلاس waiting ) استدعينى دالة بناء الكلاس reserv... ولم تسنديها للكائن ( من النوع reservation)

reservation( name ,bb,passport,1

ما علاقتها بالكائن الموجود فى الكلاس waiting ؟؟؟؟؟

هل وصلت الفكره ؟؟؟

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#5

اها مشكور اخوي وصلت الفكرة

وتلاشت كل الاخطاء ماعدا الكونستركتر

لكل الكلاسين

waiting_reservation::waiting_reservation(string name,long bb,string passport,bool m,int x):reservation r(name ,bb,passport,1)

ok_reservation::ok_reservation(string m ,long v,string g,bool 1,int s,int n,int m):reservation rr( m ,v,g,1),Date date( s, n, m)

#6

العفو .... :rolleyes:

الكلاس waiting يحتوى على كائن من النوع reserv

فى داخل دالة البناء للكلاس waiting

يمكنك استخدام دوال set للكائن ( اللى من النوع reserv) فى ادخال البيانات

name , bb ,passport, و ........

هل وصلت الفكره ؟ :)

يعنى كدا أفضل من استخدام member initailize list

وايضا مع الكلاس ok نفس الفكره

تحياتى

:)

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#7

انا الحين بديت في تاسك D

ونص السؤال هو

The Flight class is the class where actual reservation can be made. A flight has a limited number of seats and a maximum its waiting list.

When a seat is reserved for a passenger, and a vacant seat is available, a new OK reservation will be made for the passenger. If not, a new Waiting Reservation will be created if the waiting list has not reached the maximum length yet. Otherwise, no reservation will be made for the passenger.

When a reservation is cancelled, the reservation type is checked. If it is an OK Reservation and there are Waiting reservations on the list, then the OK reservation will be deleted and the first Waiting reservation on the waiting list will be removed from the list and converted to a new OK reservation for the same passenger. The rest of the waiting reservation on the waiting list will be moved forward on the list.

If the reservation to be deleted was a Waiting reservation, then the all the Waiting reservations that come after it on the list should be moved forward after deleting it.

In addition, it is possible to print the waiting list and the list of OK reservations for the flight.

وفيه فنكشن مافهمت ايش المطلوب فيها

ياليت توضحها لي

ومجددا اشكرك

class Flight{

private:

int waitingListMax;

int seats;

reservation** reservations;

public:

Flight(int capacity, int waitingMax);

bool reserveSeat(Passenger psngr, bool smoker);

void cancelReservation(string resNum);

OKReservation* confirmReservation(WaitingReservation* res);

ملف Flight.cpp

Flight(int capacity, int waitingMax){

waitingListMax=waitingMax;

seats=capacity;

reservations=new reservation*[waitingListMax];

}

bool reserveSeat(Passenger psngr, bool smoker){

passenger1.setname(psngr. getname());

passenger1.setpass(psngr.getpass());

passenger1.setcon(psngr.getcon());

smokerseat=smoke;

}

//Searches for the reservation with the given reservation number, and //deletes it. Uses the confirmReservation function if the reservation to be //deleted was an OK one

void cancelReservation(string resNum){

if(resNum==1)

cout<<" resNum is ok_reservation";

reservations=new reservation*[waitingListMax];

waitingListMax=new ok_reservation*[waitingListMax];

turn_list--;

else

cout<<" resNum is waiting _reservation";

turn_list--;

//Deletes the given waiting reservation after creating a new OK reservation //for the same passenger. Returns a pointer to the newly created reservation

OKReservation* confirmReservation(WaitingReservation* res);<<ايش الفكرة في هذي الفنكشن

#8

تكفون شباب ساعدوني لان عندي بكرة تسليم البروجكت

ولازم تشوف الاستاذة الrun

واذا ماشافته راح يتلاشى تعبي طوال الترم

(مابقالي الا تاسك d

cancelReservation بس وضحوا لي اش عمل الفنكشن

والفنكشن confirmReservation)

#9

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

الحمدلله خلصت تاسك d

بس ياليت تعدولون على هذي الفنكشن لانها ماتطلع المطلوب

او اذا فيها غلط ياليت تصصححونه لي

void flight::cancelReservation(string resnum )

{

for(int i=0;i<seats+waitinglistmax;i++)

if (( reservations != 0) && (reservations->getReservationNumber() == resnum))

if (dynamic_cast <OK_reservation*> (reservations))

delete reservations;

seatscount --;

else {

delete reservations;

seatscount --;

}

وشاكرة لكم (تكفون خلاص ارتفع ضغطي)

#10

السلام عليكم

for(int i=0;i<seats+waitinglistmax;i++)

if (( reservations != 0) && (reservations->getReservationNumber() == resnum))
if (dynamic_cast <OK_reservation*> (reservations))
{
delete reservations;
seatscount --;
}

لأن كودك يقوم بالحزف فقط دون ان يقوم بإنقاص قيمة seatscount على ما اعتقد والله أعلم

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#11

وعليكم السلام

طيب اش ممكن اسوي

الله يجزاك الجنه

#12

الحل وضعته فى الكود السابق

القوسين { }

سلام

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

مواضيع مشابهة