Obsah fóra
PravidláRegistrovaťPrihlásenie




Odpovedať na tému [ Príspevok: 1 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 19.04.07
Prihlásený: 03.01.10
Príspevky: 1
Témy: 1
Príspevok NapísalOffline : 19.04.2007 17:28

nazdarek.potreboval by som pomoct s niecim takymto:
Mam program Airport(letisko),je tam okrem ineho ze urcim vysku letu lietadiel a ja potrebujem doplnit uz len to,ze ked je vyska lietadiel rovnaka vypise nejake chybove hlasenie!
PLEASE surnejsie

program pre liedadlo( :!: spusta sa to s kodom co je nizsie,este nizie je potrebna kniznica:!: ):
airplane.cpp
Kód:
#include <iostream.h>
#include <stdio.h>
#pragma hdrstop

#include "airplane.h"
//
// Constructor performs initialization
//
Airplane::Airplane(const char* _name, int _type) :
  type(_type),
  status(ONRAMP),
  speed(0),
  altitude(0),
  heading(0)
{
  switch (type) {
    case AIRLINER : ceiling = 35000; break;
    case COMMUTER : ceiling = 20000; break;
    case PRIVATE  : ceiling = 8000;
  }
  name = new char[50];
  strcpy(name, _name);
}
//
// Destructor performs cleanup.
//
Airplane::~Airplane()
{
  delete[] name;
}
//
// Gets a message from the user.
//
bool
Airplane::SendMessage(int msg, char* response,
  int spd, int dir, int alt)
{
  //
  // Check for bad commands.
  //
  if (spd > 500) {
    strcpy(response, "Speed cannot be more than 500.");
    return false;
  }
  if (dir > 360) {
    strcpy(response, "Heading cannot be over 360 degrees.");
    return false;
  }
  if (alt < 100 && alt != -1) {
    strcpy(response, "I'd crash, bonehead!");
    return false;
  }
  if (alt > ceiling) {
    strcpy(response, "I can't go that high.");
    return false;
  }
  //
  // Do something base on which command was sent.
  //
  switch (msg) {
    case MSG_TAKEOFF : {
      // Can't take off if already in the air!
      if (status != ONRAMP) {
        strcpy(response, "I'm already in the air!");
        return false;
      }
      TakeOff(dir);
      break;
    }
    case MSG_CHANGE : {
      // Can't change anything if on the ground.
      if (status == ONRAMP) {
        strcpy(response, "I'm on the ground");
        return false;
      }
       // Only change if a non-negative value was passed.
      if (spd != -1) speed = spd;
      if (dir != -1) heading = dir;
      if (alt != -1) altitude = alt;
      status == CRUISING;
      break;
    }
    case MSG_LAND : {
      if (status == ONRAMP) {
        strcpy(response, "I'm already on the ground.");
        return false;
      }
      Land();
      break;
    }
    case MSG_REPORT : ReportStatus();
  }
  //
  // Standard reponse if all went well.
  //
  strcpy(response, "Roger.");
  return true;
}
//
// Perform takeoff.
//
void
Airplane::TakeOff(int dir)
{
  heading = dir;
  status = TAKINGOFF;
}
//
// Perform landing.
//
void
Airplane::Land()
{
  speed = heading = altitude = 0;
  status == ONRAMP;
}
//
// Build a string to report the airplane's status.
//
int
Airplane::GetStatus(char* statusString)
{
  sprintf(statusString, "%s, Altitude: %d, Heading: %d, "
    "Speed: %d\n", name, altitude, heading, speed);
  return status;
}
//
// Get the status string and output it to the screen.
//
void
Airplane::ReportStatus()
{
  char buff[100];
  GetStatus(buff);
  cout << endl << buff << endl;
}


a s tymto sa to spusta
airport.cpp
Kód:
//---------------------------------------------------------------------------
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USERES("..\Airport.res");
USEUNIT("airplane.cpp");
//---------------------------------------------------------------------------
#include "airplane.h"
int getInput(int max);
void getItems(int& speed, int& dir, int& alt);
int main(int, char **)
{
  char returnMsg[100];
  //
  // Set up an array of  Airplanes and create
  // three Airplane objects.
  //
  Airplane* planes[3];
  planes[0] = new Airplane("TWA 1040");
  planes[1] = new Airplane("United Express 749", COMMUTER);
  planes[2] = new Airplane("Cessna 3238T", PRIVATE);
  //
  // Start the loop.
  //
  do {
    int plane, message, speed, altitude, direction;
    speed = altitude = direction = -1;
    //
    // Get a plane to whom a message will be sent.
    // List all of the planes and let the user pick one.
    //
    cout << endl << "Who do you want to send a message to?";
    cout << endl << endl << "0. Quit" <<  endl;
    for (int i=0;i<3;i++)
      cout << (i + 1) << ". " << planes[i]->name << endl;
    //
    // Call the getInput() function to get the plane number.
    //
    plane = getInput(4);
    //
    // If the user chose item 0 then break out of the loop.
    //
    if (plane == -1) break;
    //
    // The plane acknowledges.
    //
    cout << endl << planes[plane]->name << ", roger.";
    cout << endl << endl;
    //
    // Allow the user to choose a message to send.
    //
    cout << "What message do you want to send?" << endl;
    cout << endl << "0. Quit" << endl;;
    cout << "1. State Change" << endl;
    cout << "2. Take Off" << endl;
    cout << "3. Land" << endl;
    cout << "4. Report Status" << endl;
    message = getInput(5);
    //
    // Break out of the loop if the user chose 0.
    //
    if (message == -1) break;
    //
    // If the user chose item 1 then we need to get input
    // for the new speed, direction, and altitude. Call
    // the getItems() function to do that.
    //
    if (message == 0)
      getItems(speed, direction, altitude);
    //
    // Send the plane the message.
    //
    bool goodMsg = planes[plane]->SendMessage(
      message, returnMsg, speed, direction, altitude);
    //
    // Something was wrong with the message
    //
    if (!goodMsg) cout << endl << "Unable to comply.";
    //
    // Display the plane's response.
    //
    cout << endl << returnMsg << endl;
  } while (1);
  //
  // Delete the Airplaine objects.
  //
  for (int i=0;i<3;i++) delete planes[i];
  return 0;
}
int getInput(int max)
{
  int choice;
  do {
    choice = getch();
    choice -= 49;
  } while (choice < -1 || choice > max);
  return choice;
}
void getItems(int& speed, int& dir, int& alt)
{
  cout << endl << "Enter new speed: ";
  getch();
  cin >> speed;
  cout << "Enter new heading: ";
  cin >> dir;
  cout << "Enter new altitude: ";
  cin >> alt;
  cout << endl;
}
//---------------------------------------------------------------------------

airplane.h
Kód:
//---------------------------------------------------------------------------
#ifndef airplaneH
#define airplaneH
//---------------------------------------------------------------------------
#define AIRLINER      0
#define  COMMUTER     1
#define  PRIVATE      2
#define  TAKINGOFF    0
#define  CRUISING     1
#define LANDING       2
#define ONRAMP        3
#define  MSG_CHANGE   0
#define  MSG_TAKEOFF  1
#define  MSG_LAND     2
#define  MSG_REPORT   3
class Airplane {
  public:
    Airplane(const char* _name, int _type = AIRLINER);
    ~Airplane();
    virtual int GetStatus(char* statusString);
    int GetStatus()
    {
    return status;
    }
     int Speed()
    {
      return speed;
    }
    int Heading()
    {
      return heading;
    }
    int Altitude()
    {
      return altitude;
    }
    void ReportStatus();
    bool SendMessage(int msg, char* response,
      int spd = -1, int dir = -1, int alt = -1);
    char* name;
  protected:
    virtual void TakeOff(int dir);
    virtual void Land();
  private:
    int speed;
    int altitude;
    int heading;
    int status;
    int type;
    int ceiling;
};
#endif
 


PLEASE....pripadne poslem program


Odpovedať na tému [ Príspevok: 1 ] 


Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy. C# alebo C++ appka/program na výpočty

v Assembler, C, C++, Pascal, Java

1

369

20.03.2015 22:36

walther Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. program na projekt (C#, C++, pascal, java)

v Assembler, C, C++, Pascal, Java

2

824

12.03.2009 12:08

Svjatogor Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. C/C++ program na pozadí

v Assembler, C, C++, Pascal, Java

4

590

27.09.2012 16:15

marian_r Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. P: APPLE Airport Express

v Predám

0

290

22.08.2017 9:41

sairik Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. P: Apple Airport Express

v Predám

0

190

27.08.2017 16:04

MakeLove Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. C++ program

v Assembler, C, C++, Pascal, Java

1

832

11.05.2008 8:23

sento Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. C program

v Assembler, C, C++, Pascal, Java

13

728

25.03.2017 11:21

mitko Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. P: Apple Airport zariadenia, Dlink, Netgear switche

v Predám

4

531

29.04.2020 22:24

maiob Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Program v C

v Assembler, C, C++, Pascal, Java

2

564

16.05.2008 16:51

Cruel Zobrazenie posledných príspevkov

Táto téma je zamknutá, nemôžete posielať nové príspevky alebo odpovedať na staršie. Program v C

v Assembler, C, C++, Pascal, Java

1

294

05.11.2013 16:00

Ďuri Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. program v C++

v Assembler, C, C++, Pascal, Java

2

1297

06.12.2006 20:44

rebecca Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. C++ zakladny program

v Assembler, C, C++, Pascal, Java

24

1602

31.08.2010 22:02

ado21 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Visal C++ program

v Assembler, C, C++, Pascal, Java

19

1115

11.09.2010 20:57

jawakiller Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Program v C++

v Assembler, C, C++, Pascal, Java

23

1130

28.05.2009 14:02

reDo Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. program v C

v Assembler, C, C++, Pascal, Java

7

739

23.05.2008 16:21

poma Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. program v C++

v Assembler, C, C++, Pascal, Java

2

533

07.06.2012 21:57

Hipi21 Zobrazenie posledných príspevkov


Nemôžete zakladať nové témy v tomto fóre
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre

Skočiť na:  

Powered by phpBB Jarvis © 2005 - 2024 PCforum, webhosting by WebSupport, secured by GeoTrust, edited by JanoF
Ako väčšina webových stránok aj my používame cookies. Zotrvaním na webovej stránke súhlasíte, že ich môžeme používať.
Všeobecné podmienky, spracovanie osobných údajov a pravidlá fóra