cis22c/03-lists/Park.cpp
Iurii Tatishchev 4ae56c5a42
6.10 Lab*: Singly-Linked Lists (Park)
Replace Park.hDisplay() with output stream operator
2024-05-02 13:03:38 -07:00

59 lines
1.5 KiB
C++

// Implementation file for the Park class
// Written By: Iurii Tatishchev
// Reviewed by: Iurii Tatishchev
// IDE: CLion
#include <iostream>
#include <iomanip>
#include <string>
#include "Park.h"
using namespace std;
// **************************************************
// Constructor
// **************************************************
Park::Park() {
code = "";
state = "";
name = "";
description = "";
year = -1;
}
// **************************************************
// Overloaded Constructor
// **************************************************
Park::Park(string cd, string st, string nm, string dsc, int yr) {
code = cd;
state = st;
name = nm;
description = dsc;
year = yr;
}
// ***********************************************************
// Displays the values of a Park object member variables
// on one line (horizontal display)
// ***********************************************************
ostream& operator<<(ostream &out, const Park &park) {
out << park.code << " ";
out << park.state << " ";
out << park.year << " ";
out << park.name << " ";
return out;
}
// ***********************************************************
// Displays the values of a Park object member variables
// one per line (vertical display)
// ***********************************************************
void Park::vDisplay() const {
cout << name << endl;
cout << " \"" << description << "\"" << endl;
cout << year << endl;
cout << state << endl;
}