Welcome to TiddlyWiki by Jeremy Ruston, Copyright © 2005 Osmosoft Limited
body {\n background-color: #f5f5ff;\n color: #0000ff;\n}\nbody a:link, body a:visited {\n color: #0000ff;\n}\n#mainMenu { background-color: #f9f9ff; }\n#mainMenu a:link, #mainMenu a:visited {\n color: #0000ff;\n}\n#mainMenu a:hover, #mainMenu a:active {\n color: #1100ff;\n background-color: #ffffff; \n}\n#displayArea {\nbackground-color: #fafafa; \n}\n.title {\n font-size:250%;\n color: #000055;\n background-color: #f9f9f9;\n}\n.toolbar A {\n color: #000000;\n}\n.toolbar A:hover {\n color: #880000;\n background-color: #ffffff; \n}\n.toolbar A:active {\n color: #ff0000;\n background-color: #ffffff; \n}\n\n#titleLine {\n background-color: #aaaadd;\n padding: .5em 1em 1em .5em;\n}\n#titleLine a:link, #titleLine a:visited { color: #0000ff; }\n#messageArea {background-color: #bbccbb; }\n#popup a{\n color: #0000ff;\n background-color: #f8f8f8; \n}\n.viewer {\n background-color: #fbfbfb; \n}\n.viewer a:link, .body a:visited {\n color: #000059;\n}\n.viewer a:hover {\n color: #000088;\n background-color: #fbfbfb; \n}\n.viewer h2,h3,h4,h5,h6 {\n background-color: #f0f0f0;\n}\n.viewer pre, .viewer code {\n font-size: 100%;\n line-height: 1.4em;\n color: #660000;\n}\n.viewer hr {\n border-top: dashed 1px #606060;\n border-left: none;\n border-right: none;\n border-bottom: none;\n height: 1px;\n color: #666666;\n}\n.tags {\n color: #aaaaaa;\n}\n.tags A {\n color: #993300;\n}\n.tags A:hover {\n color: #ccff66;\n background-color: #993300;\n}\n.tags A:active {\n color: #ffffff;\n background-color: #cc9900;\n}\n.highlight, .marked {\n color: #000000;\n background-color: #ffe72f;\n}\n.editor {\n color: #00ff00;\n}\n.editor input {\n width: 50%;\n}\n.editor textarea {\n height: 350;\n}\n.editorPrompt {\n color: #990099;\n}\n\n#sidebar {\n color: #0000ff;\n background-color: #f4f4f4;\n}\n.sidebarSubHeading {\n color: #000000;\n}\n#commandPanel {\n background-color: #eeeeee;\n color: #000000;\n}\n\n#commandPanel A {\n color: #0000ff;\n}\n\n#commandPanel A:hover {\n color: #000000;\n background-color: #ffffff;\n}\n#commandPanel A:active {\n color: #993300;\n background-color: #ccff66;\n}\n#commandPanel input {\n margin: 0.4em 0em 0.3em 1em;\n border: 1px solid #000000;\n}\n#optionsPanel {\n background-color: #eeeeaa;\n color: #444400;\n}\n\n#optionsPanel a:link, #optionsPanel a:visited {\n color: #777700;\n}\n#optionsPanel a:hover {\n color: #ffffff;\n background-color: #444400;\n}\n#sidebarTabs {\n background-color: #f4f4f4;\n}\n#sidebarTabs a {\n color: #fafafa;\n}\n#sidebarTabs a:hover {\n background-color: #aaaaaa;\n color: #000000;\n}\n#sidebarTabs a:active {\n color: #000000;\n}\n#tabTimeline {\n background-color: #e4e4e4;\n}\n#tabTags {\n background-color: #d9d9d9;\n}\n#tabMore {\n background-color: #cccccc;\n}\n.tabContentTimeline {\n background-color: #f0f0f0;\n}\n.tabContentTags {\n background-color: #e4e4e4;\n}\n.tabContentTags #popup {\n background-color: #dddddd;\n}\n.tabContentMore {\n background-color: #d9d9d9;\n}\n.tabContentMorePrompt {\n color: #ffffff;\n}\n#sidebarContent a {\n color: #000000;\n}\n#sidebarContent a:hover {\n color: #ff0000;\n background-color: #ffffff;\n}\n#licensePanel {\n visibility: hidden;\n}\n#storearea, #copyright { visibility: hidden; }\n
[[TiddlyWiki|http://www.tiddlywiki.com/]] is a single-file self-contained javascript application by Jeremy Ruston which edits, stores, and organizes small chunks of information in "tiddlers." You are now reading the [[Tiddly Wiki]] tiddler.\n\nIf you double-click on a tiddler or choose the 'edit' option, you will be able to change the text of a tiddler, but since this file is in my alpha account, you will not have permission to save your changes.\n\nIf you wish to save this file locally you will be able to edit tiddlers yourself. To get a working Tiddly Wiki, you need to do a right click save on the link to this page. file->save will mess up the application.\n\nThere are several tiddlers unrelated to the main content, which are used for bookkeeping, such as [[SiteTitle]] [[DefaultTiddlers]] and [[StyleSheet]] . Changing these can result in weird behavior.\n\nBecause the ugly 'CamelCase' is the historical way of indicating a link in a wiki, the Tiddly Wiki sometimes assumes things are links just because of how they are spelled. If you click on one, it will let you create a tiddler for that word. If you close the tiddler without putting any text in it, it will not be created.\n\nYou can search the full text of all tiddlers using the search box on the right. You can see all tiddlers listed by date last edited, by tags associated, or alphabetically, using the tabs to the right.
To create a new program in Visual Studio, you need to create a new project, and give the project a name.
! General\n* late homework will not be accepted\n* all homework must be word processed\n** in some cases -- diagrams, etc -- hand-drawn work is fine, but any text longer than a few words should be typed up.\n* work is not considered handed in until I have hardcopy\n\n! Programs\n* programs that do not run will never get more than 50% credit\n** email me your code so I can check this\n* if I ask you to use a specific file name, function name, or variable name, you may lose points for using a different name\n* programs must be turned in hardcopy and electronic (floppy)\n* programs must follow [[program formatting]] rules for full credit\n
! Program Formatting\n* you will be penalized for lack of formatting\n* each class and each function must have a brief useful explanatory comment\n** further comments as needed\n*** anywhere you do something that might not be clear to a reader\n*** anytime you're doing something you're not sure of -- explain your reasoning\n*** when I ask you to identify parts of your code\n* use descriptive class, function, and variable names\n** single letters only for counters, numbers in abstract math context\n** descriptive variable names can alleviate need for many comments\n** only class names begin with upper-case letters\n* no function may be more than 30 lines long (aim for 20!!)\n* use curly braces for all control structures (if, while, etc) even if there is only one line of code inside\n* code must use staggered indentation\n** indent inside all curly braces\n** curly braces line up with the associated construct\n* example: \n{{{\n/* return ceiling of x/2 */\nint function safeHalf (int x) {\n int halfx;\n if ((x % 2) == 0) { // is x even?\n halfx = x/2; \n } else { // if not, x+1 must be even \n halfx = (x+1)/2; \n }\n return halfx;\n}\n}}}\n
[[Start]]
{{{\n#include <ctime>\n\nint main() {\n srand(time(0));\n cout << "Your random number is " << rand() << "\sn";\n return 0;\n}\n}}}
[[Start]] \n[[Classwork 1]]\n[[Homework 1]]\n[[Homework 2]]\n[[homework policies]]
\n\nYou will use your Person.h and Person.cpp files in this program as well.\n\nCreate a class Menu (you may use mine as a model), where the menu choices are functions that look like\n\nbool addQuiz(Person * user)\n\n\nIn the main program:\n\nWrite the following functions (of the type given)\n* addQuiz \n** generate two random numbers and ask the user what their sum is\n** if the user adds correctly, add 2 points to his score and return true\n** otherwise, give him a second chance\n** if he gets it right this time, give him one point and return true\n** otherwise return false\n* subQuiz\n** do the same for subtraction\n* multQuiz\n* checkScore\n** print out the user's current score\n** always return true\n* quit\n** print out the user's score\n** say goodbye\n\n\nIn main (feel free to break things up into functions as much as you can!)\n\n* using your Menu class, create a menu with these functions\n* create two Persons using your Person class\n* * for each, get a first and last name from the command line, and start their scores at 0\n* create a Person pointer current user, and point it at the first person.\n* in a loop until someone chooses quit\n** ask the current user what menu choice they want, and run function they asked for, using the Menu\n** switch currentuser to point to the other Person\n* at the end, check which user has a higher score, and congratulate him\n\nFor extra credit\n* +5 add another quiz type and update your menu to use it\n* +5 have the size of the numbers in the quizzes based on the user's score (so maybe score <10 gets 1-digit numbers, between 10 and 20 gets 2-digit numbers, etc or make up your own system)\n* +15 instead of just two Persons, change your program so it asks how many users there are at the beginning, and keeps an array of however many Persons there are. In the loop, give each person a turn before you return to the first person again
Assignment 8
Classes
{{{\n#include <string>\nusing std::string;\nusing std::getline;\n\ncin >> string1 >> string2;\ncin.ignore(10000, '\sn');\ngetline(cin, string3);\n\nint len=string1.length();\nstring shorter = string1.substr(0,5);\n}}}\n\n{{{\n string str = "b";\n str = "a" + str + "c"; // str is now "abc"\n}}}\n\n
create a class Owl which has\n\n//variables://\n* static int IDgenerator\n* int ID\n* string location\n\n//functions://\n* constructor\n** set ID to the current value of IDgenerator, update IDgenerator\n** set location to the empty string ""\n* destructor\n* accessor for ID\n* accessor for location\n* void addLocation(string loc)\n** add loc to location, with ", " before it\n*** you may want to remind yourself about [[string]]\n\n \nMake class OwlRegistry a friend of class Owl. For this to work, you will need to declare (above the Owl class definition)\n{{{\nclass OwlRegistry;\n}}}\n\nRemember to initialize IDgenerator by saying (outside the class definition)\n{{{\nint Owl::IDgenerator = 1;\n}}}\n\ncreate a class OwlRegistry which has\n\n//variables//\n* Owl ** owlList\n* int capacity -- the size of the list\n* int numOwls -- how many owls actually registered\n\n//functions://\n* constructor\n** set capacity to 10\n** get space for owlList of size capacity (but not for any owls yet)\n** set numOwls to 0;\n* destructor\n** delete any owls we have in the list\n** delete owlList\n* void registerOwl(string location)\n** if there is room in the list (not yet up to capacity)\n*** get space for the next owl in the owlList\n*** give the new owl the location given\n*** update the number of owls\n*** print out something like "Owl #3 registered in Cambridge"\n* Owl * lookupOwl(int IDnum) {\n** go through owlList and if you find an owl with the given ID, return it\n** if not found, return NULL\n\nFunctions in OwlRegistry should take advantage of being a friend of Owl (i.e., don't go through accessors)\n\n\nWrite a program that creates an owlRegistry and registers 5 owls, found in \nSalisbury, \nBel Air, \nForest Hill, \nBaltimore, \nBel Air\n\nLook up the third owl seen and add locations Bel Air and Centerville to it\nLook up the last owl seen and add location Forest Hill to it.\n\nPrint out the location lists for these two owls.\n\n
Create a file main.cpp so you can test the class you'll write as you go along.\nCreate a header file with your usual includes, and include this instead of writing them out in main. \n\nIn a file Person.h, define a class Person with data members\n* string firstname\n* string lastname\n* int score\n\nWrite member functions\n* parameterized constructor takes first and last name\n** score starts as 0\n* destructor\n** have it print out something so you can see it run\n* accessors for data members\n* mutators for data members\n\nIn main, create three pointers to Persons, all with different names, and print their information out. Then delete them.\n\nMake sure this much works!\n\nMove the bodies of the member functions into a separate file, Person.cpp and add all the needed changes to make the program work again\n* add the class name and scope to all function names\n* add includes\n
The purpose of this assignment is to work with classes in more detail.\n\nRead Chapter 11 in the book.\n\nRead all of the assignment before you get started, this will help you plan what code you want to write first.\n\nRemember to maintain ALWAYS A WORKING PROGRAM by compiling and running early and often.\nRemember to break things up into small functions to clarify what's going on.\nRemember to use comments.\n\nYou may want to remind yourself about [[string]] and [[random numbers]].\n\n\nIn all assignments, you will be expected to read the instructions and follow them. If the instructions confuse you, disturb you, or generally cause you to question the sanity of your instructor, ask!