MasterACE14
-
Posts
2,687 -
Joined
-
Last visited
Posts posted by MasterACE14
-
-
are you missing the second curly brace in here?
function ModifyCalc($sum, $ModType, $ModValue, $OptModType, $OptModValue){ $NewSum = 0; if ($ModType >= 2 && $OptModType == 1){ eval ('$NewSum = $sum' . $ModType . '$ModValue ;'); return $NewSum; } } // to close the function
-
are you after something as simple as this?
<input type="button" value="Back" onClick="history.go(-1)">
or is it more complex than that?
-
I think eval() may be the 'simplest' solution.
eval ('$total = $firstvalue' . $symbol . '$secondvalue ;');
-
While it is 11 hours early where I am, I would like to wish everyone a happy and safe new years. If 2011 didn't turn out how you anticipated, you may have better luck in 2012!
Happy New Year!
Regards,
Ace
-
I play!
"Nexus Wars" is the best custom map!
I haven't played in several months, but Nexus Wars certainly is a lot of fun. But I do prefer the lesser known 'Income Wars', more strategy involved imo.
-
Thanks for the feedback, AyKay47. I tried what you suggested but I don't even get that far because I get an error at line: $num_rows = mysql_num_rows($result);
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/...
Maybe I need to sleep on this for a while!
something wrong with your query.
-
Living in Australia I've been with Ausweb for my domains since 2006 and never had an issue. http://domains.ausweb.com.au/
If you're after something more local, I have no idea lol
-
that's awesome.
-
I thought NaCl was salt.
I jumped into the thread thinking it was science related lol
-
Merry Christmas to you too, and a happy new year!
-
From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again.
Man, mine always told me the opposite... but this is why I say:
that in a university you cater to the professor's opinions & preferences, rather than best practicesWell at the end of the day, they're the ones marking it.
-
timeAgo2(1136622,5)
It shows:
14:03:43:42
Which is not right, it needs to show, 14 Days, 3hours 43minutes and 42 seconds.... Thank you, I finally explained myself better here, hope you understand
You do realise it is showing what you want, right?
EDIT: strike that, I see what you mean...
EDIT: With your 'if' statement, with that second example you're showing, $difference is greater than 864000, so that 'if' statement never executes for... timeAgo2(1136622,5)
-
From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again.
I shall keep in this mind.
So if you take another Programming class, ask that question the first day, "What are your coding guidelines?" and ask if you can have a print out of their guidelines. In that way you will be covered for something like this as long as you follow it. If they say they do not have any, ask for that in writing too, the best way not to get screwed over is having it in writing one way or the other. I would get that from him, if possible, and bring up the argument that "if there is no clear route for me to follow, how can I follow it?" argument.
I will definitely do this in the future, thanks!
-
I think you can use $_SERVER['SCRIPT_NAME'] instead, don't quote me on this though.
-
This is how we were apparently suppose to do it, however I don't believe this is an error on my part as I did what the question said. If it was intended to be done a certain way you'd think the question would say so, possibly providing an example input/output.
Cheers for your input, appreciated.
That's one of the things you have to watch out for as a developer. There have been numerous times where I have been tasked with something that the requester though was simple, then I ask them all kinds of questions regarding things they 'didn't think about' and soon they realize it wasn't so simple after all. There's been a few times as well where I will do just like you did and develop it in a certain way just to have it rejected and need redone because that's not what they ment.
yeah very true, that would be an absolute pain, especially if you have to start over. Good point.
-
3.1 (10 marks)
I could agree with a mark off for commenting due to this line:
float PackageWeight = 0, ShippingDistance = 0, Charge = 0, Distance = 0;
You have two different variables related to distance, but the problem description only includes one distance (what the user entered for their shipping distance). It's not obvious what the other distance variable is for until you read the code later on. There's other way to make it more obvious without necessarily having to comment on the variables, but I could agree with a mark off in general for lack of clarity.
Yeah fair call.
Instead of a fractional distance, lets treat it as blocks. 0-500, 500-1000, 1000-1500, ...
By doing that, we end up with a shipping cost of $2.20: (2.20 * (ceil(100/500)).
This is how we were apparently suppose to do it, however I don't believe this is an error on my part as I did what the question said. If it was intended to be done a certain way you'd think the question would say so, possibly providing an example input/output.
Cheers for your input, appreciated.
-
or even...
echo '<a href="#"><img src="' . $phpVariable . '" width="125" height="156" alt="some image" /></a>';
-
if (in_array($qualification, $qual))
-
this is probably what you're after. date_default_timezone_set()
-
IMO the "guideline" is the marks/comments so that you will improve next time around. Remember, school is a learning process, where you go from suck to not suck. It's not intended to be perfection every round. Also, it is a good thing to an extent to defend your work, but in the real world...you're always going to have a boss who tells you one thing and means another, and "That's not what you said" only goes so far. So, you should take this as a lesson to take it upon yourself to ask questions and get clarification on everything beforehand. Remember, the reason you (will) have the job is because you know the details, not the boss - they don't know any better, so it is up to you to pry that shit out of them.
true, I didn't think about it like that.
But anyways, yeah I agree as far as commenting. Always err on the side of over-commenting. If it's your own code that only you will ever touch, and you're confident in yourself that your naming conventions are enough for you, that's fine. But in the real world where you're working with lots of other peoples' code and they yours, there's really no such thing as too many comments.
Also want to mention that when you comment, you need to comment what your intentions are, what you are expecting to happen. The code reflects the comments, not the other way around. IOW the comments are there to explain in human language what the script is supposed to be doing. For me, my pseudo-code usually turns into my comments.
But also, comments are especially important if you're trying to track down a logic bug. The first and most important step to tracking down bugs is to figure out what it's supposed to be doing in the first place, so if you have clearly written comments then you can compare them to the actual code and more easily find those bugs. "Oh hey, it says here that I'm supposed to be doing xyz but the code clearly doesn't do that!" sort of thing.
I think I shall have to be more precise with my commenting from now on. Pseudo-code into comments is a good idea, haven't thought of that one. On reflection the variable 'Distance' in my code could of used commenting, I guess looking at it from someone else's perspective really shows how unclear it really is.
RE: commenting, you should write doc blocks before the definition of each function, including main. Write it along the lines of PHPDoc (http://www.phpdoc.org/), or whatever C++ devs usually use. That will take care of about 90% of it right there.
ah yes, completely forgot about that. I shall do this from now on!
Thanks for the feedback guys!
-
It was the first assignment, and there was no guidelines of any sort unfortunately :-\
-
I believe the point here is to teach you that people won't always see things as obviously as you do, being the one that wrote it. It's easy to, in this case, say "oh well it's obvious that PackageWeight is for a package's weight", but later on down the road you might say "well, it's obvious that PW means the package's weight" - even though it make sense if you just stared at it for 6 hours, but someone who just looks at it won't immediately know what it means.
I guess you could say "well just use good variable naming" and this is true, but sometimes it just happens.
yeah that's true, although I would of preferred that have been in the feedback rather than resulting in a deducted mark.
Fair point, thanks.
-
I can see some of the marks being taken off for part 1, but for the code (especially the commenting) I think it is BS.
I think the deducted marks there are reasonable, I should of explained in more detail. The lost mark for commenting was allegedly because I didn't comment above the variables what the variables are for, arguing that the names I gave the variables should say it all apparently isn't enough :/
I'd comment everything beyond what I thought was necessary.
yeah I shall be doing that for assignment 2.
Thanks for your opinion, appreciated!
-
Good Day everyone,
I just got my results back for my C++ assignment at uni and am not happy with the results. I've lost marks for being too accurate with my calculations and for small things like 'not enough commenting' (for variables that are self explanatory). I would like to share my results, the assignment sheet and my answers to the assignment questions as well as my program source. I have asked my lecturer and there is no assignment marking guideline for students to view, which frustrates me even more.
Assignment Sheet
Programming Fundamentals700008
Assignment 1 (10%)
Date Due: 12pm, 02/12/2011 (Week 6)
NOTE: This is an individual assignment. It is each student’s responsibility to be aware
of and adhere to the policies regarding academic misconduct. You will be asked to
modify the code and the algorithm in the week 7 tutorial class. Failure to satisfactorily
demonstrate understanding of your algorithm and the program could result in a failing
mark for parts 2 & 3.
Learning Objectives:
1. Describe and explain the purposes and operations of the basic components of a
computer and a computer system
2. Discuss and explain the concepts of data and procedural representation,
programming languages, compilers, interpreters and development environments
3. from a simple problem description, identify desired inputs, outputs, and the
necessary processing operations to convert input into output
4. design program logic using both graphical and pseudo code techniques that
employ standard control structures of sequence, iteration and selection
5. translate design structures into code in a high-level procedural language, verify
the code, and devise and implement test plans to minimise occurrence of errors
Assignment Submission Guidelines
You have to submit the following documents on vUWS before the due date.
1. Answers to Part 1 and Part 2 in MS Word (You have to include your name and
Student ID on the document.)
2. C++ Code (In the C++ code your name and Student ID should be part of a
comment at the top of the program.)
Part 1 (20 marks)
1.1 Explain the five major hardware components of a computer system. (10 marks)
1.2 Describe a) what a compiler does with a program’s source code.
b) what a linker does with a compiled code.
Part 2: Design you program (40 marks)
The Fast Freight Shipping Company charges the following rates:
Design a program that asks for the weight of the package, the distance it is to be shipped, and
displays the charges.
Input Validation: Do not accept values of 0 or less for the weight of the package. Do not accept
a weight of more than 20kg (this is the maximum weight the company will ship). Do not accept
distance of less than 10 miles or more than 3000 miles. These are the company minimum and
maximum shipping distances.
The design should include the following details.
1. IPO chart (5 marks)
2. Pseudo-code (25 marks)
3. 5 sets of test data (Test cases should be derived based on different scenarios) (7.5 marks)
4. Expected output for each test data set (2.5 marks)
Part 3: Code (40 marks)
Write the program according to your design.
1. The program should have comments and use good programming practices, such
indentation blank lines, etc. (10 marks)
2. The program should handle the logic given in the problem description (30 marks)
Assignment 1 Answers
Assignment 1Part 1)
1.1)
1 - Central Processing Unit (CPU): Performs the instructions of a computer program.
2 - Main Memory (volatile): Directly accessible by the CPU to store and read instructions.
3 - Secondary Memory/Storage (non-volatile): Not directly accessible by the CPU for storage.
4 - Input Devices: A device which can provide data to a computer.
5 - Output Devices: A device that can communicate data from the computer to the outside world.
1.2)
a) A compiler converts the source code of a programming language into a computer language.
b) The creation of a single executable file from many different object files.
Part 2)
1) IPO Chart
2) Pseudocode
Calculate_Charge Set PackageWeight to zero Set ShippingDistance to zero Set Charge to zero Get PackageWeight Get ShippingDistance IF PackageWeight <= 0 OR PackageWeight > 20 THEN Display "Package Weight must be greater than 0 and 20 or less" ELSE IF ShippingDistance < 10 OR ShippingDistance > 3000 THEN Display "Shipping Distance must be 10 or greater and 3000 or less" ELSE IF PackageWeight <= 2 THEN Charge = (ShippingDistance / 500) * 1.10 ELSEIF PackageWeight > 2 AND PackageWeight <= 6 THEN Charge = (ShippingDistance / 500) * 2.20 ELSEIF PackageWeight > 6 AND PackageWeight <= 10 THEN Charge = (ShippingDistance / 500) * 3.70 ELSEIF PackageWeight > 10 AND PackageWeight <= 20 THEN Charge = (ShippingDistance / 500) * 4.80 ENDIF Display "Total Charge is: $" Charge ENDIF ENDIF END
3) Test Data
4) Expected Output
Source Code
#include <iostream> #include <iomanip> using namespace std; int main() { float PackageWeight = 0, ShippingDistance = 0, Charge = 0, Distance = 0; cout << "Fast Freight Shipping Company :: Total Charge Calculator\n"; cout << "--------------------------------------------------------\n\n"; // prompt user for Package Weight cout << "Enter your Package Weight: "; cin >> PackageWeight; // assign the Package Weight to a variable cout << "\n"; // check the Package Weight meets our requirements, otherwise display an error message if(PackageWeight <= 0 || PackageWeight > 20) cout << "Package Weight must be greater than 0 as well as 20 or less.\n"; else { // prompt user for Shipping Distance cout << "Enter your Shipping Distance: "; cin >> ShippingDistance; // assign the Shipping Distance to a variable cout << "\n"; // check the Shipping Distance meets our requirements, otherwise display an error message if(ShippingDistance < 10 || ShippingDistance > 3000) cout << "Shipping Distance must be 10 or greater as well as 3000 or less.\n"; else { /* if no error messages have been displayed this far, perform the appropriate calculation for the Charge */ Distance = (ShippingDistance / 500); if(PackageWeight <= 2) Charge = Distance * 1.10; else if(PackageWeight > 2 && PackageWeight <= 6) Charge = Distance * 2.20; else if(PackageWeight > 6 && PackageWeight <= 10) Charge = Distance * 3.70; else if(PackageWeight > 10 && PackageWeight <= 20) Charge = Distance * 4.80; cout << setprecision(2) << fixed; cout << "Total Charge is: $" << Charge << endl; } } system("pause"); return 0; }
Marks
Programming Fundamentals70008
Marking Table
Student Id: … ******** Name: Nathan Poultney
(10 marks)
(5 marks)
(5 marks)
(5 marks)
(25 marks)
(7.5 marks)
(2.5 marks)
[td]2.5
3.1 (10 marks)
(30 marks)
Am I being too pedantic or have I been ripped off? I appreciate your thoughts.
Thanks,
Ace
add values into class file
in PHP Coding Help
Posted
create an abstract class of which those classes extend, adding new information if need be. Class Abstraction