An object-oriented approach to designing an iphone

Source: Internet
Author: User

Main.m


Edit Font Size COMMAND + <//compile Execute shortcut key COM + r#import <Foundation/Foundation.h> #import "Iphone.h" int main (int argc, const char * argv[]) {    iphone * phone = [iphone new];    Phone->_ram = +;    PHONE->_CPU = 1.5;    int year =;    int month = 7;    int day =;    NSLog (@ "Hello, world%d%d%d%@!", year,month,day,@ "starts Today");    printf ("Hello World%d%d%d\n", year,month,day);            return 0;    }


Iphone.h

#import <Foundation/Foundation.h> @interface iphone:nsobject{    //@public modified member variables, which can be directly interviewed outside the class    @public    The float _cpu;//is used to store the size of the CPU    float _ram;//is used to store the internal capacity size}//is specifically used to declare member variables-(void) aboutmyphone;-(void) Sendmessag: (Char *) content;-(void) Sendmessag: (char *) content andphonenumber: (char *) phonenumber;-(void) Sendmessagwithmessagecontent: (char *) messagecontent andphonenumber: (char *) PHONENUMBER;//2. Class Method @end


Iphone.m


#import "Iphone.h" @implementation iphone-(void) aboutmyphone{//    NSLog (@ "Aboutmyphone has been implemented");        NSLog (@ "Phone CPU%.2f,ram%.2f", _cpu,_ram);} -(void) Sendmessag: (char *) content{    NSLog (@ "%s", content);} -(void) Sendmessag: (char *) content andphonenumber: (char *) phonenumber{    NSLog (@ "Send message%s to%s", phonenumber,content) ;} -(void) Sendmessagwithmessagecontent: (char *) messagecontent andphonenumber: (char *) phonenumber{    NSLog (@ "to% s send Message%s ", phonenumber,messagecontent);} Override Description Method-(NSString *) description{    //optimize return [NSString stringwithformat:@ "My cpu=%.1f my internal storage is =%.1FMB", _cpu,_ram];    NSString *result = [NSString stringwithformat:@ "My cpu=%.1f my internal storage is =%.1FMB", _cpu,_ram];    return result;    return @ "FFFFFFFF";} @end


An object-oriented approach to designing an iphone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.