*/
Do you receive the Programmer's Heaven newsletter? If not, why not subscribe?
*/

View Battleship\src\Ship.cpp

GPL'ed Battleship clone Win32/Linux 1.2.1

Submitted By: i_like_cpp
Rating: (Not rated) (Rate It)


/*
Free Battleship clone for Win32/Linux Console.
Copyright (C) 2005  Dennis Gertitschke

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include "../inc/Ship.h"
#include <string.h>

Ship::~Ship(){
}

Frigate::Frigate(){
        length=2;
        strcpy(id,"Frigate");
}

Frigate::~Frigate(){
}

inline void Frigate::reset(){
        length=2;
}

inline int Frigate::getLength(){
        return length;
}

inline bool Frigate::getStatus(){
        if(length==0)
                return true;
        else
                return false;
}

inline char* Frigate::getId(){
        return id;
}

inline void Frigate::hit(){
        if(length)
                length--;
}

Destroyer::Destroyer(){
        length=3;
        strcpy(id,"Destroyer");
}

Destroyer::~Destroyer(){
}

inline void Destroyer::reset(){
        length=3;
}

inline int Destroyer::getLength(){
        return length;
}

inline bool Destroyer::getStatus(){
        if(length==0)
                return true;
        else
                return false;
}

inline char* Destroyer::getId(){
        return id;
}

inline void Destroyer::hit(){
        if(length)
                length--;
}

Cruiser::Cruiser(){
        length=4;
        strcpy(id,"Cruiser");
}

Cruiser::~Cruiser(){
}

inline void Cruiser::reset(){
        length=4;
}

inline int Cruiser::getLength(){
        return length;
}

inline bool Cruiser::getStatus(){
        if(length==0)
                return true;
        else
                return false;
}

inline char* Cruiser::getId(){
        return id;
}

inline void Cruiser::hit(){
        if(length)
                length--;
}

Battleship::Battleship(){
        length=5;
        strcpy(id,"Battleship");
}

Battleship::~Battleship(){
}

inline void Battleship::reset(){
        length=5;
}

inline int Battleship::getLength(){
        return length;
}

inline bool Battleship::getStatus(){
        if(length==0)
                return true;
        else
                return false;
}

inline char* Battleship::getId(){
        return id;
}

inline void Battleship::hit(){
        if(length)
                length--;
}

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.