zoukankan      html  css  js  c++  java
  • 程序员是怎么炼成的---OC题集--练习答案与题目(3)

    1init
    2initWithBytes:length:encoding:
    3
    initWithCharacters:length:
    4
    initWithCString:encoding:
    5initWithUTF8String:
    6initWithFormat:
    7
    stringWithFormat:
    8
    stringWithCharacters:length:
    9stringWithString:
    10stringWithCString:encoding:
    11stringWithUTF8String:
    12
    length
    13lengthOfBytesUsingEncoding:
    14
    characterAtIndex:
    15getCharacters:range:
    16
    cStringUsingEncoding:
    17
    UTF8String
    18
    stringByAppendingFormat:
    19stringByAppendingString:

    20stringByPaddingToLength:withString:startingAtIndex:

    21componentsSeparatedByString:

    22componentsSeparatedByCharactersInSet:
    23
    substringFromIndex:
    24substringWithRange:
    25substringToIndex:
    26
    rangeOfString:
    27rangeOfString:options:
    28rangeOfString:options:range:

    29stringByReplacingOccurrencesOfString:withString:

    30stringByReplacingOccurrencesOfString:withString:options:range:

    31stringByReplacingCharactersInRange:withString: 32caseInsensitiveCompare:
    33
    compare:
    34
    compare:options:

    35compare:options:range:

    36hasPrefix:

    37hasSuffix:

    38isEqualToString:

    39capitalizedString

    40lowercaseString

    41uppercaseString

    42doubleValue

    43floatValue

    44intValue

    45integerValue

    46longLongValue

    47boolValue

    48stringWithCapacity:
    49initWithCapacity:
    50
    appendFormat:
    51appendString:
    52deleteCharactersInRange:
    53insertString:atIndex:

    54replaceCharactersInRange:withString:

    55replaceOccurrencesOfString:withString:options:range:

    56setString:

    1array

    2arrayWithArray:

    3arrayWithObject:

    4arrayWithObjects:

    5arrayWithObjects:count:

    6init
    7initWithArray:

    8initWithObjects:

    9initWithObjects:count:

    10containsObject:

    11count

    12getObjects:range:

    13firstObject

    14lastObject

    15objectAtIndex:

    16objectsAtIndexes:

    17objectEnumerator

    18reverseObjectEnumerator

    19indexOfObject:

    20indexOfObject:inRange:

    21makeObjectsPerformSelector:

    22makeObjectsPerformSelector:withObject: 23firstObjectCommonWithArray: 24isEqualToArray: 25arrayByAddingObject: 26arrayByAddingObjectsFromArray: 27sortedArrayUsingFunction:context: 28sortedArrayUsingDescriptors: 29sortedArrayUsingSelector: 30componentsJoinedByString:

    31arrayWithCapacity: 32initWithCapacity:
    33
    addObject:
    34addObjectsFromArray: 35insertObject:atIndex: 36removeAllObjects
    37removeLastObject
    38removeObject:
    39removeObject:inRange: 40removeObjectAtIndex: 41removeObjectsInArray: 42removeObjectsInRange: 43replaceObjectAtIndex:withObject: 44setArray: 45exchangeObjectAtIndex:withObjectAtIndex: 46sortUsingDescriptors: 47sortUsingFunction:context: 48sortUsingSelector:

    三、10.18 上机作业:

    ⼀一、集合包含:NSArrayNSDictionaryNSSet。 定义三个新类,分别名为SongPlayListMusicCollectionSong对象包含着关于特

    定歌曲的信息,⽐比如歌曲名、艺术家、专辑、歌曲⻓长度等;PlayList对象包含播放列表名称 和⼀一个歌曲的集合;MusicCollection对象包含所有播放列表集合,它包括⼀一个名为Library 的主播放列表,这个列表包含该集合中的所有歌曲。定义上述的三个类,并编写⽅方法实现下 列⼈人物:

    1、创建⼀一个Song对象,并设置其信息;

    2、创建⼀一个PlayList对象,并对播放列表添加和删除歌曲。如果⼀一⾸首新歌不在主列表 中,那么将其添加进去。确保从主播放列表中删除⼀一⾸首歌时,也要从⾳音乐集合中的其他播放 列表中删除此歌曲;

    3、创建⼀一个MusicCollection对象,并对该集合添加和删除播放列表。 4、搜索并显⽰示关于所有歌曲、播放列表或整个⾳音乐集合的信息。 5、确保所有你定义的类都不产⽣生内存泄露。

    ⼆二、模拟⼀一个动物园系统MyZoo

    1、动物园⾥里⾯面有三种动物:Panda,Elephant,Kangaroo

    2、三种动物都有⼀一定的数量(不⽌止⼀一只)

    3、动物有各⾃自不同的⾷食量(以天为单位的⾷食量),并且每天都在消耗⾷食物。

    4、动物园⾥里的⾷食物有固定的储备,⽽而且假设三种动物都吃这⼀一种⾷食物。

    5、每个动物都有不同的⽣生产周期,每当到了这种动物的⽣生产周期,动物园就会出现⼀一位新 ⽣生宝宝(假设其⾷食量和成年动物是⼀一样的)

    6、在主循环⾥里模拟动物园的运转情况,要求在控制台上输出如下内容:第⼏几天、动物的数 量、动物园饲料的余量,直到饲料不够吃为⽌止。

    7、动物的数量,⾷食量,⽣生产周期,饲料总量都应该是可以配置的(在同⼀一个⽂文件中统⼀一配 置)

    三、在⼀一个遥远的国度,有个国⺩王叫⼭山鲁亚尔,他有⼀一些⾂臣民,他们的职业分别是农民,⼯工
    ⼈人和演员。农民的职责是种地,⼯工⼈人的职责是修理,演员的职责是演出。
    
      ⾂臣民们不⽤用为了⽣生计发愁,因为国⺩王会每个星期给他们发⼯工资,只是⼯工资⽔水平不同⽽而
    已。
    
      国⺩王每天的职责就是督促⼦子民们干活。
    
      由于⼯工资⽔水平⽐比较⾼高,国⺩王的积蓄有限,所以很不幸,这个可怜的国⺩王再第四周就破产
    了。
    

    要求输出内容:

    1、当前是第⼏几周的星期⼏几。 2、每⼀一天每个⼦子民的⼯工作情况:包括名字、职业和⼯工作内容。 3、每周每个⼦子民的收⼊入情况,以及他们的财富总额。 4、每周国⺩王的⽀支出总额,以及他的财富余额。 5、最后宣布国⺩王破产。

    注:每个⼦子民的初始值财富都是0。⼈人为调节国⺩王的财富和⼦子民的⼯工资,使得国⺩王在第 四周破产。

    1dictionary 2dictionaryWithDictionary: 3dictionaryWithObject:forKey:

    4dictionaryWithObjects:forKeys: 5dictionaryWithObjectsAndKeys:

    6initWithDictionary: 7initWithObjects:forKeys: 8initWithObjectsAndKeys:
    9
    count
    10
    isEqualToDictionary: 11allKeys
    12allKeysForObject: 13allValues
    14objectForKey:
    15
    valueForKey:
    16
    keyEnumerator 17objectEnumerator 18keysSortedByValueUsingSelector: 19dictionaryWithCapacity: 20initWithCapacity:

    21init 22setObject:forKey: 23setValue:forKey: 24setDictionary: 25removeObjectForKey: 26removeAllObjects 27removeObjectsForKeys:

    1set
    2setWithArray: 3setWithObject: 4setWithObjects: 5setWithSet: 6setByAddingObject: 7setByAddingObjectsFromSet: 8setByAddingObjectsFromArray: 9count
    10
    allObjects
    11
    anyObject 12containsObject:
    13
    member: 14objectEnumerator 15isSubsetOfSet: 16intersectsSet: 17isEqualToSet:

    18addObject: 19removeObject: 20removeAllObjects 21addObjectsFromArray: 22unionSet: 23minusSet: 24intersectSet: 25setSet:

    26countForObject:

  • 相关阅读:
    【11.5】生成器进阶--send、close和throw方法
    【11.4】协程是什么?
    【python】IO多路复用(select、poll、epoll)介绍及select、epoll的实现
    【11.3】select+回调+事件循环获取html
    【11.2】C10K问题和io多路复用(select、poll和epoll)
    【11.1】并发、并行、同步、异步、阻塞、非阻塞
    【10.10】进程间通信--Queue、Pipe、Manager
    set autotrace on 报cannot set autotrace 错误解决方法
    通配符获取文件
    日期函数
  • 原文地址:https://www.cnblogs.com/huntaiji/p/3427973.html
Copyright © 2011-2022 走看看