/**
 *   Løsning til eksamen i OOProg (i C++), august 2026, oppgave 1A.
 *
 *   @file     EX_S26_1A.CPP
 *   @author   Frode Haug, NTNU
 */


#include <iostream>
#include <string>
using namespace std;


class A  {
  protected:
    string txt;

  public:
    A(const string str)
       {  txt = str;  }
    bool funk3(const string s)
       {  return (txt.find_first_of(s, 0) != string::npos);  }
    virtual void funk4(const char c)
       {  txt = (c <= 'K') ? "Arsenal" : "Wrexham";  }
    virtual void funk5()  {  cout << 'A';  }
};


class B : public A {
  private:
    char ch;
    int tall;

  public:
    B(const string s, const char c, const int t) : A(s)
       {  ch = c;  tall = t;  }
    void funk1()
       { cout << (txt + ',' + ch + '-' + to_string(tall));  }
    void funk2()
       {  txt.clear();  for (int i = 0;  i < 5;  i++) txt += ch;  ch = 'E';  }
    void funk4(const char c)
       {  ch = (c < 'S') ? 'X' : 'Y';   A::funk4(c); }
    void funk5()  {  cout << 'B';  }
};


int main() {
  B  b1("25/1-ManU", 'U', 116);
  B* b2 = new B("24/1-QPR", 'C', 82);

  b1.funk1();  cout << ' ';  b2->funk1();  cout << '\n';

  b2->funk2();   b2->funk1();  cout << '\n';

  cout << b1.funk3("-/") << ' ' << b1.funk3("u") << ' '
       << (*b2).funk3("-/") << '\n';

  b2->funk4('P');   b2->funk1();  cout << '\n';

  delete b2;
  A* a = new A("Banan");
  b2 = reinterpret_cast <B*> (a);
  b2->funk5();    cout << '\n';

  return 0;
}




//  Utskrift:  25/1-ManU,U-116 24/1-QPR,C-82
//             CCCCC,E-82
//             1 0 0
//             Wrexham X-82
//             A
