|
|
#1 |
|
Registered User
Join Date: Sep 2012
Posts: 1
|
Need help coding basic Objective-C
Hello, I am new here an unsure if this the right place to be posting but I am in need of help coding some basic Obective-C
I am new to it and am taking a class at my local university where I have been assigned this. Develop a class named Box (or ABox) if necessary. A Box object should have three iVars: • Sender’s Name: NSString • length: float type (in inches, such as 33.123) • width: float type (in inches, such as 12.2345) • height: float type (in inches, such as 8.50) Each of these ivars should have matching property declarations and subsequently synthesized. Do not use any hardcoded getters or setters. At the least, it should have two instance methods. These are: 1. computeVolume • Should not receive any parameters • Should compute the volume of a box object and return float. By the way, the volume is computed as length * width * height (in cubic inches). 2. estimateCategory • Should not receive any parameters • Should return “Large” if the volume is more than or equal to 8000 cubic inch • Should return “Medium” if the volume is more than or equal to 1000 cubic inch and less than 8000 cubic inches. • Should return “Small” if the volume is less than 1000 cubic inches. It should also override the inherited description method that will return a formatted string with the values of iVars. (Either see our OOP example 4 or 5, or see http://brandontreb.com/objective-c-t...iption-method/, or see Chapter2/Textbook1) The consumer of the class will: • Create one or more boxes (one at a time) and display the string (on the Log) received from the description method. • Should receive the returned values from the two other methods (one at a time) and will display strings like “The Volume of the box is: 9999.99” with two digits after decimal or the “Estimated category of the box is Large (or whatever the category). Test the above class extensively all probable scenarios and document the results with appropriate screen shots. The displayed information (on the Log) should be easily understandable. ____ I don't even know where to start. I would greatly appreciate any help. Feel free to code it yourself if you are up to it. |
|
|
|
|
|
#2 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 31,941
|
Start by going through all of the examples provided in the textbook you are using (you do have a book I hope) and the examples that Apple provides e.g. in their Xcode/ Interface Builder tutorial.
__________________
hayne.net/macosx.html |
|
|
|
|
|
#3 | ||||||||||||||||||||||||||||||||||||||||||||||
|
League Commissioner
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
|
Like Hayne said, your textbook would be a great place to start.
That would be doing your homework for you, wouldn't it? One place I notice that is easy to get sidetracked on is the 'cubic inches' bit. If your input variables are floats then your output will be in cubic units, not inches. Mention to your teacher that the rest of the world went metric in 1976, with Myanmar, Liberia and the USA being the only holdouts. And you can score extra brownie points if you include a bounds checker, for example if l=1.2; w=2.1; h=75 it's possible that l and w are in units and h is in centiunits, which will make a mess of the results. |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#4 | |||||||||||||||||||||||
|
All Star
Join Date: Aug 2009
Posts: 664
|
Clearly time and money is being wasted on your "education". |
|||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|