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)
--- Rumpf Implementierungen (http://www.informatikerboard.de/board/thread.php?threadid=2919)


Geschrieben von progger am 25.03.2016 um 15:09:

 

Was machst du da genau mit dem min und max in der Aufgabe?

verwirrt



Geschrieben von eulerscheZahl am 25.03.2016 um 15:25:

 

min berechnet das Minimum, max das Maximum.
Mit min(bottomLeft.x, topRight.x); finde ich ich x-Wert, der weiter links liegt.



Geschrieben von progger am 28.03.2016 um 10:17:

 

void setCorners (CPoint bottomLeft, CPoint topRight);

/**
* Liefert die linke untere Ecke des Rechtecks zurück.

Ich verstehe nicht welche Zusicherung die meinen ?

Vielleicht die die wir gerade implementiert haben ?

void setCorners (CPoint bottomLeft, CPoint topRight){

if(m_bottomLeft.x = min(bottomLeft.x, topRight.x)){

m_bottomLeft = bottomLeft;

}





Und für topRight diese Zusicherung beachten ?
m_topRight.x = max(bottomLeft.x, topRight.x); ?

Diese Aufgabe ist irgendwie schwer zu verstehen?

}



Geschrieben von eulerscheZahl am 28.03.2016 um 10:30:

 

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
	/**
	 * Weist den Eigenschaften "linke untere Ecke" und "rechte obere
	 * Ecke" neue Werte zu.
	 *
	 * Vor der Zuweisung wird die Zusicherung überprüft, dass die
	 * rechte obere Ecke rechts von und oberhalt der linken
	 * unteren Ecke liegen muss! Ist das nicht der Fall wird keines
	 * der Attribute verändert.
	 */

Wie prüfst du, ob die eine Ecke links oberhalb der anderen ist? Was muss für den x Wert gelten und was für y?
Du brachst hier kein min oder max, einfach nur > und <.

Zitat:
if(m_bottomLeft.x = min(bottomLeft.x, topRight.x)){

Eine Zuweisung in einer if Abfrage ist wirklich keine gute Idee.



Geschrieben von progger am 28.03.2016 um 11:03:

 

Das sind doch diese bedingungen oder ?

In dem vorigen code :

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
CRectangle::CRectangle(CPoint bottomLeft, CPoint topRight, char fillChar)
{
       m_topRight= topRight;
	if(topRight.x < bottomLeft.x) {
		m_bottomLeft.x = bottomLeft.x;
	}
if(topRight.x > bottomLeft.x) {
		m_bottomLeft.y = bottomLeft.y;
	}
	if(topRight.y < bottomLeft.y) {
		m_bottomLeft.y = bottomLeft.y;
	}
if(topRight.y > bottomLeft.y) {
		m_bottomLeft.x = bottomLeft.y;
	}

}



Soll ich diese bedingungen einbauen?



Geschrieben von progger am 30.03.2016 um 11:44:

 

Stimmt meine Idee so eulersche Zahl?



Geschrieben von eulerscheZahl am 30.03.2016 um 11:46:

 

Nein.



Geschrieben von progger am 30.03.2016 um 22:10:

 

Gute Antwort großes Grinsen

Wie prüfst du, ob die eine Ecke links oberhalb der anderen ist?

Ich weiss es nicht .

Woran merke ich denn dass die Ecke links oberhalb ist?



Geschrieben von eulerscheZahl am 31.03.2016 um 07:58:

 

Ich sehe ehrlich gesagt die Schwierigkeit nicht.
Ein Punkt ist unten links von einem anderen, wenn sein x und y Wert kleiner sind als der des anderen Punktes.
Und das "wenn" noch ins Englische übersetzen, mehr ist das nicht.
code:
1:
2:
3:
4:
if (bottomLeft.x <= topRight.x && bottomLeft.y <= topRight.y) {
	m_bottomLeft = bottomLeft;
	m_topRight = topRight;
}



Geschrieben von progger am 02.04.2016 um 14:16:

 

Die Aufgabe ist wiklich langweilig irgendwie großes Grinsen

großes Grinsen

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:
#include "CRectangle.h"

CRectangle::CRectangle(char fillChar)
{
	m_fillChar = fillChar;
}

CRectangle::CRectangle(CPoint bottomLeft, CPoint topRight, char fillChar)
{
       m_topRight= topRight;
	if(topRight.x < bottomLeft.x) {
		m_bottomLeft.x = bottomLeft.x;
	}
if(topRight.x > bottomLeft.x) {
		m_bottomLeft.y = bottomLeft.y;
	}
	if(topRight.y < bottomLeft.y) {
		m_bottomLeft.y = bottomLeft.y;
	}
if(topRight.y > bottomLeft.y) {
		m_bottomLeft.x = bottomLeft.y;
	}






}

void CRectangle::setCorners(CPoint bottomLeft, CPoint topRight)
{
	if (bottomLeft.x <= topRight.x && bottomLeft.y <= topRight.y) {
		m_bottomLeft = bottomLeft;
		m_topRight = topRight;
	}
}

CPoint CRectangle::getBottomLeftCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_BottomLeftCorner();
}

CPoint CRectangle::getTopRightCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_TopRightCorner();
}

void CRectangle::setFillChar(char fillChar)
{
	// Bitte implementieren
}

char CRectangle::getFillChar() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return 0;
}

bool CRectangle::operator ==(const CRectangle& other) const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return false;
}

void CRectangle::draw(CScreen& screen) const
{
	// Bitte implementieren
}






Stimmen die get und set Methoden?



Geschrieben von progger am 04.04.2016 um 11:21:

 

ne Idee Zahl ?



Geschrieben von eulerscheZahl am 05.04.2016 um 08:44:

 

code:
1:
2:
3:
4:
5:
6:
7:
void CRectangle::setCorners(CPoint bottomLeft, CPoint topRight)
{
	if (bottomLeft.x <= topRight.x && bottomLeft.y <= topRight.y) {
		m_bottomLeft = bottomLeft;
		m_topRight = topRight;
	}
}

ja, das stimmt.

code:
1:
2:
3:
4:
5:
CPoint CRectangle::getBottomLeftCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_BottomLeftCorner();
}

das ist falsch, du hast keine Funktion m_BottomLeftCorner().
Richtig wäre return m_bottomLeft;.

Für topRight gilt das selbe.



Geschrieben von progger am 07.04.2016 um 21:11:

 

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
CPoint CRectangle::getBottomLeftCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_bottomLeft();
}

CPoint CRectangle::getTopRightCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_topRight();
}






code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
void CRectangle::setFillChar(char fillChar)
{
	m_fillChar = fillChar;
}

char CRectangle::getFillChar() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_fillChar;
}




Kannst du bisschen versuchen zu erklären was man bei der f) machen muss ?

Verstehe nicht so genau was die wollen großes Grinsen



Geschrieben von eulerscheZahl am 08.04.2016 um 06:29:

 

code:
1:
2:
3:
4:
5:
CPoint CRectangle::getBottomLeftCorner() const
{
	// Bitte implementieren und dabei das return-Statement ersetzen.
	return m_bottomLeft();
}

Das ist falsch. m_bottomLeft ist keine Funktion, sondern eine Variable. Deshalb kommen da auch keine Klammern dahinter.

Operatorüberladung hatten wir schon hier: C++ Einführung



Geschrieben von net am 14.04.2016 um 17:08:

 

Einfach mittels Cout ausgeben ?

Mist alles wieder vergessen großes Grinsen


Forensoftware: Burning Board, entwickelt von WoltLab GmbH