11453 - Online course (bonus)   

Description

In this problem, students can use accounts to take online courses.

The program architecture is explained as follows.

 

A. Definition of class Student

  • An abstract base class that declares pure virtual learn() method
  • Has a string (note) used to record what the student learns
  • Derived classes
    • InterestedStudent
      • Just note the latest thing
    • StrivingStudent
      • Note everything learned

 

B. Definition of class Account

  • A node of doubly linked list

 

C. Definition of class OnlineCourse

  • An abstract base class that declares pure virtual material() method
  • Operator+= means login
    • A student can use an account to login an online course.
  • Operator-= means logout
    • If a student has been taking an online course, he/she can logouts the online course.
  • Derived classes
    • Math
      • The input will be a pre-order expression with +, -, *, /
      • material() method has to return the answer of the expression
    • English
      • The input will be a string
      • material() method has to separate the characters of the input string by new lines if a next character is uppercase

 

You are asked to implement

  • void InterestedStudent::learn(const string &str)
    • The Student learns the material by saving the input str to the note.
  • void StrivingStudent::learn(const string &str)

    • Note: if he/she learns something, you need to attach a new line and then the new material to the “note”.
  • void OnlineCourse::operator+=(Student *s)

    • create an Account for the Student and insert the Account to the doubly linked list.

    • Note:

      • A student cannot login a same course for more than one time.

      • But a student can logout a course, and then login again.

  • void OnlineCourse::operator-=(Student *s)

    • remove the Account for the Student from the doubly linked list and then delete the Account.

  • string Math::material(istream &input)

  • string English::material(istream &input)

    • Note: you don’t need to insert a new line before the first character, even if it’s uppercase.

 

 

Input

First line contains an integer n and n types from {m, e}

  • Integer n means n online courses
  • type m means Math
  • type e means English

Second line contains an integer m and m types from {i, s}

  • integer m means m students
  • type i means InterestedStudent
  • type s means StrivingStudent

and then, there are 4 kinds of commands

  • i n m:

m-th student logins n-th course

  • o n m:

m-th student logouts n-th course

  • u n:

there are new input for n-th course

  • s m:

show the note of m-th student

 

 

Output

the output depends on the input commands.

 

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

11453.cpp

Partial Judge Header

11453.h

Tags




Discuss