Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
-- Praktische Informatik (http://www.informatikerboard.de/board/board.php?boardid=6)
--- Neue Aufgabe c++ (http://www.informatikerboard.de/board/thread.php?threadid=2966)


Geschrieben von eulerscheZahl am 15.05.2016 um 08:01:

 

Nein unglücklich
numSeats ist eine lokale Variable. Verwende sie auch!
code:
1:
numSeats*m_pricePerTicket



Geschrieben von progger am 15.05.2016 um 10:49:

 

Warum lässt man das m_ weg?

Warum wird der Spamschutz Code nicht mehr angezeigt?



Geschrieben von eulerscheZahl am 15.05.2016 um 11:50:

 

Weil die Variable nicht m_numSeats heißt.

Du schreibst bei der Deklaration
code:
1:
void CEvent::print(unsigned long numSeats){

das m_ steht für member und deutet an, dass es sich um eine Klassenvariable handelt (ich persönlich mag die ungarische Notation nicht).



Geschrieben von progger am 15.05.2016 um 20:22:

 

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:

#include <iostream>
using namespace std;
#include "CEvent.h"

CEvent::CEvent( eType type , string name ,string datetime , string location ,unsigned long int maxSeats, float pricePerTicket){
	m_type = type;
	m_name = name;
	m_datetime = datetime;
	m_location = location;
	m_pricePerTicket = pricePerTicket;

	if(m_maxSeats >=0 ){

		m_maxSeats = maxSeats;



	}

	if(m_maxSeats <= 0){

		m_maxSeats = 0;
	}



}



eType CEvent::getType(){

	return m_type;
}

string CEvent::getLocation(){

	return m_location;
}

unsigned long CEvent::getNumAvailSeats(){

	return m_maxSeats-m_bookedSeats;
}

string CEvent::getTypeAsString(eType type){

	if(m_type = NOTYPE){
	return "Unbekannter Typ";

	}

	if(m_type = THEATER){
		return "THEATER";

		}

	if(m_type = ROCKPOP){
		return "ROCKPOP";

		}

	if(m_type = SCIENCE){
		return "SCIENCE";

		}

	if(m_type = NUMTYPES){
		return "Unbekannter Typ";

		}

}

void CEvent::print(unsigned long numSeats){
	if (numSeats == 0){
		cout << " Objektinfo: " << m_location << " " << m_type << " :  " << m_datetime << " Einzelpreis : " << m_pricePerTicket  << endl;




}
if (numSeats != 0){
	cout <<  m_type << "  25x " << m_name << m_location << " : " <<  m_datetime <<  " Gesamtpreis: " <<  m_pricePerTicket << endl;





 }
   numSeats*m_pricePerTicket;
}

bool CEvent::book(unsigned long numSeats){
	this->getNumAvailSeats();
	 if(this->getNumAvailSeats()== 0){

		 cout<< "Keine Plätze vorhanden "<< endl;
		 return false;} else {

			 m_bookedSeats += numSeats;
			 this->print(numSeats);
			 return true;
		 }
	 }




Stimmt der eingebaute Code so ?



Geschrieben von progger am 15.05.2016 um 20:28:

 

Wie soll ich hier die freie position im Array einbauen?


code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:

#include <iostream>
using namespace std;
#include "CEvent.h"
#include"CEventDB.h"

CEventDB::CEventDB(int maxEvents ){

	if(m_maxEvents >= 10 ){

		m_maxEvents = maxEvents;
	}

	if(m_maxEvents <= 10 ){

			m_maxEvents = 10;
		}

	m_pEvents = new CEvent[maxEvents];
}






Geschrieben von progger am 17.05.2016 um 20:00:

 

Weisst du was ich genau bei der b) machen soll ?


Forensoftware: Burning Board, entwickelt von WoltLab GmbH