gballoon.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 64 行

H
64
字号
#ifndef _GBALLOON_H
#define _GBALLOON_H

// class for balloon manipulation using simulated auto pilot
// (based on an idea of Dave Reed)
// modified: 8/30/94, 12/29/94, 11/3/95
// graphics version 3/22/99
//
// member function explanation:
//
// Ascend: rise to specified height in a sequence of burns
//         Each burn raises the altitude by 10 meters
//
// Cruise: cruise for specified time-steps/seconds
//         Random wind-shear can cause balloon to rise and fall,
//         but vents and burns keep ballon within 5 m. of start altitude
//
// Descend:   descend to specified height in sequence of vents
//            Each vent drops the balloon 10 m. or to ground if < 10 m.
//
// int GetAltitude: returns altitude (in meters)  (y-coord)
// int GetLocation: returns how many time steps/secs elapsed (x-coord)

#include "canvas.h"
#include "utils.h"

class Balloon
{
  public:
  
    Balloon();                    // use default color (gold)
    Balloon(color c);             // balloon of specified color
    
    void Ascend  (int height);    // ascend so altitude >= parameter 
    void Descend (int height);	  // descend so altitude <= parameter 
    void Cruise  (int steps);	  // cruise for parameter time-steps 
    
    int GetAltitude() const;      // returns height above ground (y-coord)
    int GetLocation() const;      // returns # time-steps (x-coord)
    
  private:
    
    void Create(color c);
    
    void Burn();
    void Vent();
    void AdjustAltitude();
    
    void Display();
    void Message();
    
    int myAltitude;
    int mySteps;
    Mover * myShape;
    TextShape * myLegend;
    static AnimatedCanvas ourCanvas;
    static int ourCount;
    int myCount;
    int myDisplayHeight;
    
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?