Loading problems/LabThree_ChapterNine.h +63 −9 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ // Chapter 9 /** * This class represents a student, with the following elements: * - A student has a name (string) and quiz score(s) (int). * - A student can be constructed with a name, or with a name and a quiz score. * - A student has an appropriate destructor. * - Quiz scores can be added, one at a time, to a student object with a method addQuizScore. * - A student has a method getAverageScore() that returns the average * This class represents a student with the following properties: * - It has a name (string) and quiz score(s) (int). * - It can be constructed with a name, or with a name and a quiz score. * - It has an appropriate destructor. * - Quiz scores can be added, one at a time, to it with a method addQuizScore. * - It has a method getAverageScore() that returns the average * of all scores entered for the student. * * @example Loading @@ -26,8 +26,62 @@ class labThree_pTwo { /** * This class * This class represents a person with the following properties: * - It has a constructor that creates a person with a given name * (as a string) and no friends. * - It has member functions matching the signatures below. * * @example * labThree_pThree person1("Jim"); * labThree_pThree person2("Jane"); * labThree_pThree person3("Bob"); * * person1.befriend(person2); * person1.befriend(person3); * person2.befriend(person1); * * person1.getFriendCount() - returns 2 (friends) * person2.getFriendCount() - returns 1 (friend) * person3.getFriendCount() - returns 0 * * person1.getFriends() - returns "Jane, Bob" * person2.getFriends() - returns "Jim" * * person1.getFriendOfFreinds() - returns "Jim" * person2.getFriendOfFriends() - returns "Jane, Bob" * */ class labThree_pThree { // fill this in here /** * Adds thePerson as a friend of this person. * @param thePerson person to add as a friend. */ void befriend(labThree_pThree thePerson); /** * Removes thePerson as a friend of this person. If the * person was not a friend, then this does nothing. * @param thePerson The person to remove. */ void unfriend(labThree_pThree thePerson); /** * @return The number of friends this person has. */ int getFriendCount(); /** * @return A comma-separated list of the names of all friends * of this person, in any order. */ string getFriends(); /** * * @return A comma separated list of the names of all friends * of the friends of this person, in any order. */ string getFriendsOfFriends(); }; No newline at end of file problems/LabZero.cpp 0 → 100644 +113 −0 Original line number Diff line number Diff line // CHAPTER 2 /** * @input read in three values, one per line, from the user relating to a triangle: * a - the length of one side * b - the length of a neighboring side * gamma - the angle between the sides corresponding to a and b. * @output the length of the the third side of the triangle, as a floating-point * number, using the law of cosines. * * @example * Side a: 1 * Side b: 2 * gamma: 90 * 1.41421 */ void labZero_pZero() { // YOUR CODE HERE } /** * @input read in two times in military format (e.g., 0900, 1730). * @output the number of hours and minutes between the two * times, in the format "[h] hours [m] minutes" for appropriate * values [h] and [m]. * * @example 1 * Please enter the first time: 0900 * Please enter the second time: 1730 * 8 hours 30 minutes * * @example 2 * Please enter the first time: 1730 * Please enter the second time: 0900 * 15 hours 30 minutes */ void labZero_pOne() { // YOUR CODE HERE } /** * @input read in an integer with up to 6 digits. * @output the sum of the digits of the number. * * @example: * Please enter the number: 123456 * 21 */ void labZero_pTwo() { // YOUR CODE HERE } // CHAPTER 3 /** * @input read in four integers on one line. * @output "in order" if the integers are in strictly * ascending or descending order. Otherwise, output * "not in order" * * @example: * 1 2 3 4 * in order */ void labZero_pThree() { // YOUR CODE HERE } /** * @input read in four pairs of integral x y coordinates, one per line. * @output outputs the most specific description of the * four points among the following choices: * square, rectangle, trapezoid, rhombus, none of these * * @example 1 * 0 0 * 0 1 * 1 0 * 1 1 * square * * @example 2 * 0 0 * 0 1 * 2 0 * 1 1 * trapezoid */ void labZero_pFour() { // YOUR CODE HERE } /** * @input read in a positive integer. * @output The Roman numeral corresponding to the input, using the * rules described in problem P3.13 of the book. * * @example 0 * 14 * XIV * * @example 1 * 1978 * MCMLXXVIII */ void labZero_pFive() { // YOUR CODE HERE } No newline at end of file Loading
problems/LabThree_ChapterNine.h +63 −9 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ // Chapter 9 /** * This class represents a student, with the following elements: * - A student has a name (string) and quiz score(s) (int). * - A student can be constructed with a name, or with a name and a quiz score. * - A student has an appropriate destructor. * - Quiz scores can be added, one at a time, to a student object with a method addQuizScore. * - A student has a method getAverageScore() that returns the average * This class represents a student with the following properties: * - It has a name (string) and quiz score(s) (int). * - It can be constructed with a name, or with a name and a quiz score. * - It has an appropriate destructor. * - Quiz scores can be added, one at a time, to it with a method addQuizScore. * - It has a method getAverageScore() that returns the average * of all scores entered for the student. * * @example Loading @@ -26,8 +26,62 @@ class labThree_pTwo { /** * This class * This class represents a person with the following properties: * - It has a constructor that creates a person with a given name * (as a string) and no friends. * - It has member functions matching the signatures below. * * @example * labThree_pThree person1("Jim"); * labThree_pThree person2("Jane"); * labThree_pThree person3("Bob"); * * person1.befriend(person2); * person1.befriend(person3); * person2.befriend(person1); * * person1.getFriendCount() - returns 2 (friends) * person2.getFriendCount() - returns 1 (friend) * person3.getFriendCount() - returns 0 * * person1.getFriends() - returns "Jane, Bob" * person2.getFriends() - returns "Jim" * * person1.getFriendOfFreinds() - returns "Jim" * person2.getFriendOfFriends() - returns "Jane, Bob" * */ class labThree_pThree { // fill this in here /** * Adds thePerson as a friend of this person. * @param thePerson person to add as a friend. */ void befriend(labThree_pThree thePerson); /** * Removes thePerson as a friend of this person. If the * person was not a friend, then this does nothing. * @param thePerson The person to remove. */ void unfriend(labThree_pThree thePerson); /** * @return The number of friends this person has. */ int getFriendCount(); /** * @return A comma-separated list of the names of all friends * of this person, in any order. */ string getFriends(); /** * * @return A comma separated list of the names of all friends * of the friends of this person, in any order. */ string getFriendsOfFriends(); }; No newline at end of file
problems/LabZero.cpp 0 → 100644 +113 −0 Original line number Diff line number Diff line // CHAPTER 2 /** * @input read in three values, one per line, from the user relating to a triangle: * a - the length of one side * b - the length of a neighboring side * gamma - the angle between the sides corresponding to a and b. * @output the length of the the third side of the triangle, as a floating-point * number, using the law of cosines. * * @example * Side a: 1 * Side b: 2 * gamma: 90 * 1.41421 */ void labZero_pZero() { // YOUR CODE HERE } /** * @input read in two times in military format (e.g., 0900, 1730). * @output the number of hours and minutes between the two * times, in the format "[h] hours [m] minutes" for appropriate * values [h] and [m]. * * @example 1 * Please enter the first time: 0900 * Please enter the second time: 1730 * 8 hours 30 minutes * * @example 2 * Please enter the first time: 1730 * Please enter the second time: 0900 * 15 hours 30 minutes */ void labZero_pOne() { // YOUR CODE HERE } /** * @input read in an integer with up to 6 digits. * @output the sum of the digits of the number. * * @example: * Please enter the number: 123456 * 21 */ void labZero_pTwo() { // YOUR CODE HERE } // CHAPTER 3 /** * @input read in four integers on one line. * @output "in order" if the integers are in strictly * ascending or descending order. Otherwise, output * "not in order" * * @example: * 1 2 3 4 * in order */ void labZero_pThree() { // YOUR CODE HERE } /** * @input read in four pairs of integral x y coordinates, one per line. * @output outputs the most specific description of the * four points among the following choices: * square, rectangle, trapezoid, rhombus, none of these * * @example 1 * 0 0 * 0 1 * 1 0 * 1 1 * square * * @example 2 * 0 0 * 0 1 * 2 0 * 1 1 * trapezoid */ void labZero_pFour() { // YOUR CODE HERE } /** * @input read in a positive integer. * @output The Roman numeral corresponding to the input, using the * rules described in problem P3.13 of the book. * * @example 0 * 14 * XIV * * @example 1 * 1978 * MCMLXXVIII */ void labZero_pFive() { // YOUR CODE HERE } No newline at end of file