📄 car.cbl
字号:
$set mfoo
*------------------------------------------------------------
*
* This class was derived from following C++ implementation.
*
*----- Start of car.h
*
* #ifndef __CAR_H
* #define __CAR_H
*
* #ifndef __VEHICLE_H
* #include "Vehicle.h"
* #endif
*
* #ifndef __CLLLRPHN_H
* #include "ClllrPhn.h"
* #endif
*
* #ifndef __MOTOR_H
* #include "Motor.h"
* #endif
*
* #ifndef __PASSENGR_H
* #include "Passengr.h"
* #endif
*
* #ifndef __TIRE_H
* #include "Tire.h"
* #endif
*
* const int maxNumberOfTires = 4;
* const int maxNumberOfPassengers = 4;
*
* class Car : public Vehicle
* { int speed;
* int totalCarsBuilt;
* int initialNumber;
* CellularPhone* currentCellularPhone;
* Motor currentMotor;
* Passenger* currentPassengers [6 ];
* Tire currentTires [6 ];
*
*----- I do not understand the difference between the definition
*----- of currentCellularPhone (association) and currentMotor
*----- (aggregation). In Object COBOL these are both defined as
*----- object references.
*
*----- The size of the currentPassenger and currentTires arrays
*----- appears to default to 6 base upon a literal in the code
*----- code generation script. In Object COBOL, I leave it up to
*----- the developer to create a array with a default size.
*
* public:
*
* void registerIt () ;
*
* void move () ;
*
* void operate () ;
*
* void makePhoneCall () ;
*
* void inflateTire () ;
*
* void checkPassengerSeatBelt () ;
*
* };
*
* #endif
*
*----- End of car.h
*----- Start of car.cpp
*
* #include "Car.h"
*
* void Car::registerIt()
* {
*
* }
*
* void Car::move()
* {
*
* }
*
* void Car::operate()
* {
*
* }
*
* void Car::makePhoneCall()
* {
*
* }
*
* void Car::inflateTire()
* {
*
* }
*
* void Car::checkPassengerSeatBelt()
* {
*
* }
*----- End of car.cpp
*------------------------------------------------------------
* Insert your description of class car here
*------------------------------------------------------------
Class-id. car
data is protected
inherits from vehicle
with data.
Object section.
*------------------------------------------------------------
* Insert names of other classes used here
*------------------------------------------------------------
Class-control.
Vehicle is class "vehicle"
Car is class "car"
Passenger is class "passengr"
CellularPhone is class "clllrphn"
Tire is class "tire"
Motor is class "motor"
Array is class "array"
.
*------------------------------------------------------------
* Insert shared data declarations here (class and instance).
*------------------------------------------------------------
working-storage section.
$set sourceformat(free)
77 char pic x is typedef.
77 uns-char pic 9(2) comp-5 is typedef.
77 short pic s9(4) comp-5 is typedef.
77 uns-short pic 9(4) comp-5 is typedef.
77 int pic s9(9) comp-5 is typedef.
77 uns-int pic 9(9) comp-5 is typedef.
77 long pic s9(9) comp-5 is typedef.
77 uns-long pic 9(9) comp-5 is typedef.
77 d-l-float comp-2 is typedef.
77 d-float comp-2 is typedef.
77 float comp-1 is typedef.
77 proc-pointer procedure-pointer is typedef.
77 data-pointer pointer is typedef.
77 void pic 9(2) comp-5 is typedef.
$set sourceformat(fixed)
78 maxNumberOfTires value 4.
78 maxNumberOfPassangers value 4.
*------------------------------------------------------------
* Insert your class data declarations here
*------------------------------------------------------------
object-storage section.
*------------------------------------------------------------
* Add any class initialization code to the procedure division
*------------------------------------------------------------
procedure division.
exit program.
Method-id. "classMethod".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "classMethod".
object.
*------------------------------------------------------------
* Insert your object instance data declarations here
*------------------------------------------------------------
object-storage section.
01 speed int.
01 totalCarsBuilt int.
01 initialNumber int.
01 currentCellularPhone object reference.
01 currentMotor object reference.
01 currentPassengers object reference.
01 currentTires object reference.
Method-id. "registerIt".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "registerIt".
Method-id. "move".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "move".
Method-id. "operate".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "operate".
Method-id. "makePhoneCall".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "makePhoneCall".
Method-id. "inflateTire".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "inflateTire".
Method-id. "checkPassengerSeatBelt".
*------------------------------------------------------------
* Insert your data declarations here
*------------------------------------------------------------
local-storage section.
linkage section.
*------------------------------------------------------------
* Insert your procedure specification here
*------------------------------------------------------------
procedure division.
exit method.
end method "checkPassengerSeatBelt".
end object.
end class car.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -