Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 3.14 average. Display Modes
Old 09-12-2012, 10:24 PM   #1
blackfuse
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.
blackfuse is offline   Reply With Quote
Old 09-13-2012, 04:20 PM   #2
hayne
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
hayne is offline   Reply With Quote
Old 09-13-2012, 07:06 PM   #3
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
Quote:
Originally Posted by blackfuse
I don't even know where to start. I would greatly appreciate any help.

Like Hayne said, your textbook would be a great place to start.

Quote:
Originally Posted by blackfuse
Feel free to code it yourself if you are up to it.

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.
acme.mail.order is offline   Reply With Quote
Old 09-14-2012, 11:32 PM   #4
onceagain
All Star
 
Join Date: Aug 2009
Posts: 664
Quote:
Originally Posted by blackfuse
Feel free to code it yourself if you are up to it.

Clearly time and money is being wasted on your "education".
onceagain is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.