hey guys, great forum. this is my first post, i have been learning objective c for a few weeks now and i have made a program to help me with work, its kind of a calculator. i programmed it in cmd line utility, foundation tool. i would like to get the program ready for a GUI. i have designed a GUI already in interface builder, but i know i need to do a lot of work on my code i.e creating IVars, methods, setters, and getters (i think
) but working with objects seems a little confusing at first, although i am getting there. but could any body point me in the right direction as where to start with it. or just tell me i am bonkers and to start again
i guess any response would be great goo or bad. anyhow here is the main file with my code
Code:
#import <foundation/Foundation.h>
int main(int argc, char const * argv [])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
float sand = 50;
float totalNumWalls = 0;
float wallLength = 0;
float heightOfWall = 0;
float areaOfMeters = 0;
float pricePer = 0;
float bagsPlaster = 10;
char choice;
options///////////////////////////////////////////////////////////////////////////////
NSLog(@" Please choose an option...\n");
NSLog(@" --------------------------");
NSLog(@"1) Calculates the area, price, and amount of bags needed for internal skimming.");
NSLog(@"2) Calculates area, price, and amount of sand nedded for external render.");
NSLog(@"3) Calculates area, price, and amount of plaster needed for ceilings.");
NSLog(@"q) Quits the program.");
scanf("%c", &choice);
-----------------------------------------------------------------------------options//
// price per squared meter/////////////////////////////////////////////////////////
NSLog(@"Please enter a price per m2");
scanf("%f",&pricePer);
NSLog(@"£%.2f", pricePer);
switch (choice)
{
//------------------------------------------------------------------------------price//
// calculates price, area, and amount of bags needed for internal skimming///
case '1':
NSLog(@"Please enter an overall height of the wall");
scanf("%f", &heightOfWall);
for(;;)
{
NSLog(@"Please enter length of wall. Enter a negative number to finish");
scanf("%f",&wallLength);
NSLog(@"%.1f", wallLength);
if (wallLength <= 0)
{
break;
}
totalNumWalls += wallLength;
}
NSLog(@"Area = %.1f sq'Meters", totalNumWalls * heightOfWall);
NSLog(@"price = £%.2f", totalNumWalls * heightOfWall * pricePer);
NSLog(@"amount of plaster needed = %.1f Bags", totalNumWalls * heightOfWall / bagsPlaster);
break;
//------------------------------------------------------------------------skimming//
// calculates price, area, and amount of sand needed for external rendering//
case '2':
for(;;)
{
NSLog(@"please enter length of wall. Enter a negative number to finish ");
scanf("%f",&wallLength);
if (wallLength <=0)
{
break;
}
NSLog(@"please enter height of wall.");
scanf("%f", &wallLength);
areaOfMeters = wallLength * wallLength;
//totalNumWalls += areaOfMeters;
}
NSLog(@"Area = %.1f sq'Meters", areaOfMeters /*totalNumWalls*/);
NSLog(@"price = £%.2f", areaOfMeters /*totalNumWalls*/ * pricePer);
NSLog(@"Amount of sand needed = %.1f Ton", areaOfMeters /*totalNumWalls*/ / sand);
NSLog(@"\n");
break;
//------------------------------------------------------------------------rendering//
// calculates price, area, and amount needed for single areas or ceilings/////
case '3':
for(;;)
{
NSLog(@"please enter length of ceiling. Enter a negative number to finish ");
scanf("%f",&wallLength);
if (wallLength <=0)
{
break;
}
NSLog(@"please enter width of ceiling.");
scanf("%f", &wallLength);
areaOfMeters = wallLength * wallLength;
//totalNumWalls += areaOfMeters;
}
NSLog(@"Area = %.1f sq'Meters", areaOfMeters /*totalNumWalls*/);
NSLog(@"price = £%.2f", areaOfMeters /*totalNumWalls*/ * pricePer);
NSLog(@"amount of plaster needed = %.1f Bags ", areaOfMeters /*totalNumWalls*/ / bagsPlaster);
NSLog(@"\n");
break;
//---------------------------------------------------------------------------ceilings//
// default option if the user enters a wrong option///////////////////////////////
default:
NSLog(@"That is not an option");
//---------------------------------------------------------------------------default//
}
[pool drain];
return 0;
}