#ifndef _PROMPT_H #define _PROMPT_H #include "apstring.h" // facilitates prompting for int, double or string // Owen Astrachan // 1/8/95, // 12/97, modified for PromptlnXX // 06/98, modified for apstring // // PromptRange: used for int or double entry // // int PromptRange(apstring prompt,int low, int high) // -- returns int in range [low..high] // Example: // int x = PromptRange("enter weekday",1,7); // // generates prompt: enter weekday between 1 and 7 // // double PromptRange(apstring prompt,double low, double high) // -- returns int in range [low..high] // Example: // double d = PromptRange("enter value",0.5,1.5); // // generates prompt: enter value between 0.5 and 1.5 // // apstring PromptString(apstring prompt) // -- returns a string // Example: // apstring filename = PromptString("enter file name"); // // bool PromptYesNo(apstring prompt) // -- returns true iff user enter yes // (or any string beginning with y, only strings beginning with y or // n are accepted) // // Example: // if (PromptYesNo("continue?")) // DoStuff(); // else // Quit(); // // // Note: all functions PromptXXX have PromptlnXXX equivalent // which read an entire line (getline) instead of just an int, // double, string, etc. long int PromptRange(apstring prompt,long int low, long int high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) long int PromptlnRange(apstring prompt,long int low, long int high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) // reads an entire line int PromptRange(apstring prompt,int low, int high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) int PromptlnRange(apstring prompt,int low, int high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) // reads an entire line double PromptRange(apstring prompt,double low, double high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) double PromptlnRange(apstring prompt,double low, double high); // precondition: low <= high // postcondition: returns a value between low and high (inclusive) // reads an entire line apstring PromptString(apstring prompt); // postcondition: returns string entered by user apstring PromptlnString(apstring prompt); // postcondition: returns string entered by user, reads entire line bool PromptYesNo(apstring prompt); // postcondition: returns true iff user enters "yes" (any string with // 'y' as first letter, only 'y' and 'n' strings accepted) bool PromptlnYesNo(apstring prompt); // postcondition: returns true iff user enters "yes" (any string with // 'y' as first letter, only 'y' and 'n' strings accepted) // reads entire line #endif