/*
This file implements a class called Phone, which
represents Mobile Phones. Methods allow manipulation
of the Phone , such as Calling, Sending Sms, Playing Games
Listen to Music and Navigate in the Net
*/
#import <Foundation/Foundation.h>
//----- @ Interface section ---------
@interface Phone: NSObject
-(NSString *) getColor;
-(NSString *) getName;
-(float) getPrice ;
-(int) getIdPhone ;
-(void) setColor: (NSString *) pColor ;
-(void) setName: (NSString *) pName ;
-(void) setPrice : (float) pPrice ;
-(void) setIdPhone : (int) pIdPhone ;
-(void) sendSms : (NSString *) pSms ;
-(void) callNumber : (int) pNumber ;
-(void) openUrl: (NSString *) pUrl ;
-(void) listenMusic : (NSString *) pSongToListen ;
-(void) playGame : (NSString *) pGameName ;
-(void) print;
@end
//----- @ Implementation section ---------
@implementation Phone{
int IdPhone ;
float price ;
NSString* name ;
NSString* color;
}
-(NSString *) getColor{
return color;
}
-(NSString *) getName{
return name;
}
-(float) getPrice {
return price ;
}
-(int) getIdPhone {
return IdPhone;
}
-(void) setColor: (NSString *) pColor {
color=pColor;
}
-(void) setName: (NSString *) pName {
name=pName;
}
-(void) setPrice : (float) pPrice {
price=pPrice;
}
-(void) setIdPhone : (int) pIdPhone {
IdPhone=pIdPhone;
}
-(void) sendSms : (NSString *) pSms {
// hope That I will learn it soon :p
NSLog(@"Your SMS has been sent !");
}
-(void) callNumber : (int) pNumber {
NSLog(@"Calling ...");
}
-(void) openUrl: (NSString *) pUrl {
NSLog(@"Loading ...");
}
-(void) listenMusic : (NSString *) pSongToListen {
NSLog(@"Listening ...");
}
-(void) playGame : (NSString *) pGameName {
NSLog(@"Playing ...");
}
-(void) print {
// didn't know how to make them in the same NSLog :s
// keep getting The message :
// Format string is not a string literal (potentially insecure)
// but it works anyway :p I am just a beginner
NSLog(@"Name : ");
NSLog(name);
NSLog(@"Color : ");
NSLog(color);
NSLog(@"Price :");
NSLog(@"%.2f",price);
}
@end
// Main Program Section
int main(int argc, const char * argv[]){
@autoreleasepool{
Phone *galaxyS3 = [[Phone alloc] init];
[galaxyS3 setName:@"Galaxy S3"];
[galaxyS3 setColor:@"White"];
[galaxyS3 setIdPhone:1];
[galaxyS3 setPrice:700];
[galaxyS3 print];
[galaxyS3 sendSms:@"Hello Moto"];
[galaxyS3 playGame:@"Angry Birds"];
[galaxyS3 callNumber:001657422115];
[galaxyS3 openUrl:@"http://www.google.com"];
}
}