Can some one look at my code

Write your question here.

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
#include <cstdlib>
#include <iostream>
#include <cmath>
#include "../../hdrMain/exploreMain.h"

enum fit{ RoomEnough, TooHigh, TooWide, TooSmall };

struct ship
{
    string name;
    float beam;
    float height;
    float length;

};

struct bridge
{
    string name;
    float width;
    float height;
    float length;
};

string display (can_pass ( Bridge, Ship));

fit can_pass ( bridge thisBridge, ship thisShip )
{
    if (( thisBridge.height > thisShip.height ) && ( thisBridge.width > thisShip.length ))
        return(RoomEnough);
    if ( thisBridge.height < thisShip.height )
        return( TooHigh);
    if ( thisBridge.width < thisShip.length )
        return( TooWide );
    if (( thisBridge.height < thisShip.height ) && ( thisBridge.width < thisShip.length ))
        return ( TooSmall);

}


string display (can_pass( bridge, ship))
{
    if (can_pass == TooWide)
        return ("Too wide to pass the bridge.");
    if ( can_pass == TooSmall)
        return ( "The ship is to wide and to tall to pass the bridge.");
    if (can_pass == TooHigh)
        return ("Too tall to pass the bridge.");
    if ( can_pass == RoomEnough )
        return ("Yes, it can go through the bridge!");
}


its giving me errors
|25|error: expected primary-expression before ',' token|
|25|error: expected primary-expression before ')' token|
|65|error: expected ';' before 'display'|
|41|error: redefinition of 'std::string display'|
|25|error: 'std::string display' previously declared here|
|41|error: expected primary-expression before ',' token|
|41|error: expected primary-expression before ')' token|
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
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include "../../hdrMain/exploreMain.h"

using namespace std;

enum fit{ RoomEnough, TooHigh, TooWide, TooSmall };

struct ship
{
    string name;
    float beam;
    float height;
    float length;
};

struct bridge
{
    string name;
    float width;
    float height;
    float length;
};

string display (fit);

fit can_pass ( bridge thisBridge, ship thisShip )
{
    if (( thisBridge.height > thisShip.height ) && ( thisBridge.width > thisShip.length ))
        return(RoomEnough);
    if ( thisBridge.height < thisShip.height )
        return( TooHigh);
    if ( thisBridge.width < thisShip.length )
        return( TooWide );
    if (( thisBridge.height < thisShip.height ) && ( thisBridge.width < thisShip.length ))
        return ( TooSmall);
    // undefined return if thisBridge.height == thisShip.height
}

string display (fit can_pass)
{
    if (can_pass == TooWide)
        return ("Too wide to pass the bridge.");
    if ( can_pass == TooSmall)
        return ( "The ship is to wide and to tall to pass the bridge.");
    if (can_pass == TooHigh)
        return ("Too tall to pass the bridge.");
    if ( can_pass == RoomEnough )
        return ("Yes, it can go through the bridge!");
}
Last edited on
Topic archived. No new replies allowed.