Object-Oriented Programming I Fall 2018
CIS 3100
Programming Assignment 6
For this assignment, you are to implement the String class, the specification of which is shown
below. Using this String class you are then to implement an application to sort a sequence of
words input by the user. This application should begin by asking the user how many words, not
to exceed 100, are to be input. Once the user has input a valid value, your program should then
prompt the user to enter each of the words that are to be sorted, with one prompt per word being
used. After the last word has been input, the program should sort the word in ascending order,
and then out the words, one per line
For this assignment, you may use any of the Cstring functions available in C++.
In addition to the application that you are implementing, I will also supply you with a main()
function that will be used to test your code.
Due Date: December 18, 2018
String Class Specification:
class String {
private:
char strval[101]; //holds string value
public:
//constructors
String(); //initializes default value of null
//string
String(char s[]); //initializes string to value of
//cstring s
//access functions
void ToCstring(char s[]); //convert value to cstring s
bool EqualTo(String s); //true if value equal to s
//else false
bool LessThan(String s); //true if value less than s,
//else false
bool GreaterThan(String s); //true if value greater than
//s, else false
int Length(); //returns length of string
String Concat(String s); //returns concatenation of s
//to string value
//modifier functions
//No modifier function specified
//input/output functions
void Read(); //reads in string value from
//istream, no prompt given
void Write(); //outputs string value to
//ostream, no newline inserted
//destructor
//No destructor defined.
};
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。