obj c 画 图形 过程式开发
来源:互联网 发布:淘宝收藏店铺怎么设置 编辑:程序博客网 时间:2024/05/04 18:38
再次“复习”下过程式语言的繁琐
//// main.m// shapes-Procedural//// Created by Wunderman on 11-12-28.// Copyright (c) 2011年 __MyCompanyName__. All rights reserved.// 过程式开发//#import <Foundation/Foundation.h>typedef enum { kCircle, kRectangle, kOblateSpheroid} ShapeType;typedef enum { kRedColor, kGreenColor, kBlueColor} ShapeColor;typedef struct { int x, y, width, height;} ShapeRect;typedef struct { ShapeType type; ShapeColor fillColor; ShapeRect bounds;} Shape;void drawShapes(Shape shapes[], int count);void drawCircle(ShapeRect bounts, ShapeColor fillColor);NSString *colorName(ShapeColor colorName);int main (int argc, const char * argv[]){ @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); Shape shape[3]; ShapeRect bounds_0 = {0, 0, 10, 30}; shape[0].type = kCircle; shape[0].fillColor = kRedColor; shape[0].bounds = bounds_0; ShapeRect bounds_1 = {1, 1, 11, 31}; shape[1].type = kRectangle; shape[1].fillColor = kGreenColor; shape[1].bounds = bounds_1; ShapeRect bounds_2 = {2, 2, 12, 32}; shape[2].type = kOblateSpheroid; shape[2].fillColor = kBlueColor; shape[2].bounds = bounds_2; drawShapes(shape, 3); } return 0;}void drawShapes(Shape shapes[], int count) { int i; for(i = 0; i<count; i++) { switch (shapes[i].type) { case kCircle: drawCircle(shapes[i].bounds, shapes[i].fillColor); break; case kRectangle: //drawRectangle(shapes[i].bounds, shapes[i].fillColor); break; case kOblateSpheroid: //drawOblateSpheroid(shapes[i].bounds, shapes[i].fillColor); break; default: break; } }}void drawCircle(ShapeRect bounts, ShapeColor fillColor) { NSLog(@"drawing a circle at (%d, %d, %d, %d) in %@", bounts.x, bounts.y, bounts.width, bounts.height, colorName(fillColor));}NSString *colorName(ShapeColor colorName) { switch (colorName) { case kRedColor: return @"red"; break; case kGreenColor: return @"green"; break; case kBlueColor: return @"blue"; break; default: break; }}
阅读全文
0 0
- obj c 画 图形 过程式开发
- Windows程式开发设计指南--图形基础
- 过程式数据库对象
- 过程式编程方法
- 过程式编程
- IOS OOP-过程式编程
- obj-c 开发相关基本名词解释…
- HELLOWIN程式---HELLOWIN.C
- 第一個C程式
- 如何成为一个游戏制作人——第三章:过程式编程语法(详细请自学<<C++Primer>>)
- Objective-C基础之面向对象编程(OOP)的基础知识(2)——了解过程式编程
- 面向对象编程 VS 过程式编程
- 过程式编程vs.面向对象编程
- 过程式编程-绘图程序
- (WPF)XAML 过程式代码
- C++Directx11开发笔记三:绘制图形
- Obj-C & webservice
- Obj-C & webservice
- @property 和 @synthesize
- 字符编码(二)校验码
- 关于LNK2005的错误
- 论文素材 Yolo
- 字符编码(三) 字节序、bit序、 有效位
- obj c 画 图形 过程式开发
- 1057. 数零壹(20)
- Objective-c 面向对象画图形(此程序不符合内存管理规则)
- TCP/IP 协议簇学习
- C++11 std::bind std::function 变参函数
- 夜间模式的切换的实现方式
- win7激活工具终极版本
- servlet 总结
- error: Semantic Issue: Interface type cannot be statically allocated