Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geico Command #54

Merged
merged 13 commits into from
Nov 4, 2013
Merged

Geico Command #54

merged 13 commits into from
Nov 4, 2013

Conversation

brytonmoeller
Copy link

I have created a Geico command that involves golf clubs. I am sorry for any mistakes. Im still getting used to Github.

rytonbay added 5 commits October 17, 2013 15:20
different golf clubs save you different amounts
@brytonmoeller
Copy link
Author

I apologize for that pull request, please ignore it. That was not the version I intended to use.

@brytonmoeller
Copy link
Author

Now the file is correct, i apologize again, i am very new to Github

@jgonggrijp
Copy link
Member

Welcome, rytonbay, and thank you for your effort. It is fine to be a beginner, we all were once. Also, this project explicitly welcomes beginners and the practice of "fooling around".

There are bugs in your program. For example on line 17: it tests whether insurancecost is an int, which it can't be because it was returned by raw_input (which always returns a string). So your program happily tells me that 100 is not an integer. :) There are other things that would need to be done as well, before your program can be merged.

I'll add comments to your last commit to point out the problems. Please take your time to address them and feel free to ask for help whenever you need it. You can ask your questions here, on IRC (#redspider at foonetic.net) or in the forum thread. We also have a wiki which may answer some of your questions and is worth having a look at anyway.

Please post here again when you think all bugs are solved. :)

@@ -0,0 +1,44 @@
#! /usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python may mean "Python 2" on some systems and "Python 3" on others. Your program seems to assume Python 2 so you may have to change this to python2. Alternatively, you can add the following line after line 7:

from __future__ import print_function

and then use print as a function everywhere, i.e. wrap what is printed in parentheses. That would make your program compatible with both Python 2 and Python 3.

@WesleyAC
Copy link
Contributor

Note that setup.py won't install this, because it's not in it's list of programs to install.
Also, it doesn't respond to -h and /doc/ doesn't have a geico.txt in it.

@jgonggrijp
Copy link
Member

All true, but let's not pile up all remaining tasks at once.

@jgonggrijp jgonggrijp mentioned this pull request Oct 20, 2013
rytonbay added 2 commits October 22, 2013 21:33
i still have work to do on other files but the command should be
looking better
i also added Geico.py to the setup and made a few changes to Geico.py
@@ -0,0 +1 @@
Geico Help:Prompt 1: How much does your insurance currently cost?: reply with an integer, do not use a $ sign or a decimal value.Prompt 2: Which golf club would you like to use to threaten your agent?: reply with "Putter", "5iron", "7iron", "Wood" or "Driver"Prompt 3: How intimidating can you look with a [your club choice]? (1-10): reply with an integer (it can bee less than 1 or greater than ten as long as it is an integer, this can be used to save LOTS of money)how does it work?: total cost = insurancecost * (1 - (insurance saving percent based on club choice + (strength/100)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your program is fairly straightforward to use, so it's not really necessary to explain its usage so meticulously.

It would be nice if you could explain something about the idea behind your program. For example, you could write something humorous about why people need your program. It would also be interesting to know why the program is called "Geico".

Lastly, it would be good to remove the ".py" from the filename.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all of the help, I am having trouble testing it for many reasons but Wesley and I are making progress towards a solution. Also, I agree with your opinions on the help file (which I named incorrectly anyway), that was just a first draft which I will continue editing.

--Bryton

Sent from your iPhone

On Oct 24, 2013, at 11:10 AM, Julian Gonggrijp [email protected] wrote:

In doc/Geico.py.txt:

@@ -0,0 +1 @@
+Geico Help:

Prompt 1: How much does your insurance currently cost?: reply with an integer, do not use a $ sign or a decimal value.

Prompt 2: Which golf club would you like to use to threaten your agent?: reply with "Putter", "5iron", "7iron", "Wood" or "Driver"

Prompt 3: How intimidating can you look with a [your club choice]? (1-10): reply with an integer (it can bee less than 1 or greater than ten as long as it is an integer, this can be used to save LOTS of money)

how does it work?:

total cost = insurancecost * (1 - (insurance saving percent based on club choice + (strength/100)))
Your program is fairly straightforward to use, so it's not really necessary to explain its usage so meticulously.

It would be nice if you could explain something about the idea behind your program. For example, you could write something humorous about why people need your program. It would also be interesting to know why the program is called "Geico".

By the way, things would be more readable with a few newlines.


Reply to this email directly or view it on GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to hear that!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So two quick things:
A. When replying to github issues via email, don't include the original
email in the reply.
B. The ?: morestuff thing in the prompts look a little funny. Maybe move
the : to the end of the extended prompt?

@jgonggrijp
Copy link
Member

@rytonbay It seems you have solved most issues, well done...

But...

Do you test your code before you push it? There are still some problems in Geico and I presume you would have found them if you had tested the program (but if I'm wrong please say so). I think there are a few things in particular that you should pay attention to:

  • Does the output look the way you meant it? Is it formatted correctly (with the right number of newlines, etc.)?
  • How does the program behave when you give correct input all the way through to the end?
  • How does the program behave when you enter "banana" as the insurance cost?
  • How does the program react to other incorrect output?

If this is just hocus pocus to you, let me know and I'll add some more inline comments to the diff.

@jgonggrijp
Copy link
Member

The new help text is much better!

I would still change a few things:

  • Remove the colon at the end of the first line.
  • Move the line about the command being inspired on xkcd no. 42 close to the top.
  • Move the line about how it works to the bottom, and reformat to make it independent of previous text.
  • Hard wrap the text (i.e. break lines when you go beyond some fixed width, for example 70 characters).

How's it going with the program? Do you just need more time or should I help out?

@brytonmoeller
Copy link
Author

I will make those changes to the help text. I figured out how to test my program so it is now fully functional, i think. The directions on GitHub for using the Red Spider Project don't work for me so i will post an issue at some point. I am using the latest OSX, i have made some progress towards a solution.

@lramati
Copy link

lramati commented Oct 27, 2013

Generally code gets hardwrapped at 80 characters

@jgonggrijp
Copy link
Member

@firerogue: true, but my comment on wrapping to (for example) 70 characters was about the help text.

@rytonbay: you believe your program is now fully functional, but it seems you haven't pushed any new changes in the past two days. Do I understand correctly that you still need to publish the fixes for your program? I'll look out for your other issue.

@brytonmoeller
Copy link
Author

I think that the program is fully functional, I thought I pushed changes but I must have forgotten. My help text is not finished.

Sent from your iPhone

On Oct 27, 2013, at 5:14 PM, Julian Gonggrijp [email protected] wrote:

@firerogue: true, but my comment on wrapping to (for example) 70 characters was about the help text.

@rytonbay: you believe your program is now fully functional, but it seems you haven't pushed any new changes in the past two days. Do I understand correctly that you still need to publish the fixes for your program? I'll look out for your other issue.


Reply to this email directly or view it on GitHub.

@jgonggrijp
Copy link
Member

Testing

(For the other platforms.)

git remote add bryton git://github.com/rytonbay/the-red-spider-project.git
git fetch bryton
git checkout bryton/master
src/Geico.py  # try both correct and incorrect inputs

@jgonggrijp
Copy link
Member

I tested it on Windows 7 and it all worked fine.

@mrhmouse
Copy link
Contributor

I'm able to input nonsensical numbers.

# python2 src/Geico.py
How much does your insurance currently cost?: -9001
Putter costs 175$ but saves you 10 percent on insurance.
5iron costs 100$ but saves you 15 percent on insurance.
Wood costs 225$ but saves you 22 percent on insurance.
7iron costs 100$ but saves you 17 percent on insurance.
Driver costs 350$ but saves you 26 percent on insurance.
Which golf club would you like to use to threaten your agent?: Driver
How intimidating can you look with a golf club? (1-10): 9001
Your insurance will cost $803429.26, but you will have to pay $350 to purchace your club.

I would think that insurance cost should be a positive, non-zero number. Also, the "intimidation" number doesn't check that the supplied input is between the bounds it suggests (1 - 10).

@mrhmouse
Copy link
Contributor

Also, the formatting is inconsistent for money values. In the golf club prompts, the amounts are formatted as amount$ (which is non-standard), while the final output formats amounts as $amount. There is also a minor spelling error: "purchace" should be "purchase".

@mrhmouse
Copy link
Contributor

When I am at the first prompt ("How much does your insurance currently cost?"), I can't exit the program with ^C (Control-C).

@jgonggrijp
Copy link
Member

For completeness' sake, mrhmouse tested Geico on Linux, so the program has now been tested on all platforms.

@mrhmouse: good idea to test whether ^c works.

@rytonbay, I suggest you deal with these test results as follows:

  • As far as I'm concerned you don't have to check that numbers are within range yet. Please don't give that priority over the other points. Getting the program ready for the merge is more important now, more fixes can (and should) be done after that in another pull request.
  • The dollar notation is easy to fix, just do that.
  • The ^c problem is caused by the program catching all exceptions, which includes KeyboardInterrupt, which is what is thrown when the user presses ^c. The solution is to only catch the exception you're interested in, which is ValueError. You do so by changing both instances of except: into except ValueError:.

After you've fixed the latter two points and the fixes to the doc are ready, I think we can merge your program. :)

if you user inputs a negetive # for insurence cost or intimidation than
the computer treats it as positive
@brytonmoeller
Copy link
Author

I fixed the things you suggested except the 1-10 range checking issue. I want to keep that in there for people who are extra intimidating. [hahaha]

@jgonggrijp
Copy link
Member

Looking good. Now it's just a matter of those last few changes to the help file and we're set.

wrapped text  and rearranged
jgonggrijp added a commit that referenced this pull request Nov 4, 2013
With two additional commits affecting the formatting of doc/Geico.txt.

Conflicts:
	setup.py
@jgonggrijp jgonggrijp merged commit c0610cf into the-xkcd-community:master Nov 4, 2013
@jgonggrijp
Copy link
Member

Great! It's merged. Congratulations with your first completed contribution!

The text wrapping doesn't seem to have come through, so I re-wrapped the doc. While I was at it I also made a small tweak to the line "how it works". I hope you don't mind.

I recommend that you now do git pull upstream master on your local clone and then run ./setup.py.

If you want to continue working on Geico, please do git checkout -b geico first. This creates a branch with the name geico where you can separate all work that is related to Geico from all other work (even if it's somebody else's work). You can switch back and forth between your branches with git checkout master and git checkout geico (or git checkout whatever-you-have). Make sure to commit (or stash) your changes before switching between branches. You can push branches separately.

Please do anything else you start working on on a separate branch as well, and name the branch after the business you're working on. Base new branches always on the latest versions of master (as always there are exceptions to this rule of thumb but don't worry about that yet). So:

git checkout master
git pull upstream master
git checkout -b new-branch-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants