Fayzan Task 7.1P.pdf - #include\"splashkit.h#include <string>#include <vector> using std:vector using namespace std struct knight_data string name int

Fayzan Task 7.1P.pdf - #include"splashkit.h#include...

  • Deakin University
  • SIT 102
  • fayzanls02
  • 9
  • 100% (20) 20 out of 20 people found this document helpful

This preview shows page 1 - 3 out of 9 pages.

#include "splashkit.h" #include <string> #include <vector> using std ::vector; using namespace std ; struct knight_data { string name; int age; string quest; vector<string> items; }; struct kingdom_data { string name; vector<knight_data> knights; }; string read_string ( string prompt ) { string result; write (prompt); result = read_line (); return result; } int read_integer ( string prompt ) { string line; line = read_string (prompt); return convert_to_integer (line); } knight_data read_knight () { knight_data result; result . name = read_string ( "Enter Name: " ); result . age = read_integer ( "Enter Age: " ); result . quest = read_string ( "Enter Quest: " ); result . items . push_back ( read_string ( "Enter Items: " )); return result;
} void write_knight ( const knight_data & knight ) { write_line ( knight . name + " Aged " + to_string ( knight . age ) + " Your Quest i s " + knight . quest + " Your Items are " ); for ( int i = 0 ; i < knight . items . size (); i++) { write_line ( knight . items [i]); } } enum knight_update_option { UPDATE_NAME , UPDATE_AGE , UPDATE_QUEST , ADD_ITEMS , FINISH_UPDATE }; knight_update_option read_knight_update_option () { int result; write_line ( "1: Update Name" ); write_line (

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture