斯坦福iPhone开发教程:自定义类与内存管理(2010冬第3课)

需积分: 10 1 下载量 3 浏览量 更新于2024-07-30 收藏 606KB PDF 举报
本篇文档是斯坦福大学2010年冬季的iPhone应用开发教程CS193P-Lecture3,主要关注Objective-C编程语言中的自定义类、属性以及内存管理,特别是垃圾回收机制。课程在1月12日举行,主要内容包括: 1. **作业提交**:作业1A和1B截止日期为1月13日,学生被鼓励提前提交,并可通过邮件 cs193p@cs.stanford.edu 提问。作业内容涉及对Foundation工具的延续,需要添加自定义类,并介绍基础内存管理。 2. **课程进度与覆盖主题**:2A作业是上一阶段的继续,重点在于扩展对Foundation工具的理解,要求学生添加自定义类,并掌握基本的内存管理策略。2B作业则是进入第一个iPhone应用程序开发阶段,涵盖的主题将在1月14日的课程中讨论,包含详尽的步骤指导。 3. **在线资源**:课程讲座已开始在iTunesU平台上更新,但可能会晚于作业截止日期发布,提醒学生们及时查看。同时,教师办公室时间安排为Paul周四下午2-4点在Gates B26B,David周一下午4-6点在Gates 360。 4. **课程回顾与提问**:课程开始时,讲师可能回顾了上一阶段的作业问题,并引导学生创建自定义类,这是iOS应用开发的核心组成部分,理解如何设计和实现自定义对象至关重要。 5. **内存管理**:这部分教学内容深入到Objective-C的内存管理,包括autorelease(自动释放池)的概念,它在程序中负责管理和释放对象的内存,确保内存的高效使用,防止内存泄漏。 通过学习本节课程,学生将对Objective-C语言有更深入的理解,学会如何构建和扩展自定义类,同时掌握关键的内存管理技巧,这对于编写高效、健壮的iPhone应用程序至关重要。此外,课程还强调了及时提交作业和利用在线资源的重要性,确保学生跟上课程进度。

补全以下代码private String cid;// Course id, e.g., CS110. private String name;// Course name, e.g., Introduce to Java Programming. private Integer credit;// Credit of this course private GradingSchema gradingSchema; //Grading schema of this course // enum GradingSchema{FIVE_LEVEL, PASS_FAIL} private Integer capacity;// Course capacity. private Integer leftCapacity;// Course capacity left. You should update the left capacity when enrolling students. private Set<Timeslot> timeslots;// One course may have one or more timeslots. e.g., a lecture in Monday's 10:20-12:10, and a lab in Tuesday's 14:00-15:50. public Course(String cid, String name, Integer credit, GradingSchema gradingSchema, Integer capacity) // constructor public void addTimeslot(Timeslot timeslot) //Record a timeslot for this course private Integer id;// A unique student id, should be an 8-digit integer: Undergraduates' ids should start with 1; Postgraduates' ids should start with 3. e.g., 12213199. private String name;// Student’s name private Map<Course, Grade> courses;// Enrolled courses, using Map structure to store course and its grade as a pair. Grade is an enum type enum Grade{PASS,FAIL,A,B,C,D,F}with an attribute: Double gradePoint protected Student(Integer id, String name) // constructor public abstract boolean canGraduate() // Checks if this student satisfies all the graduating conditions. Hint: you are allowed to change this abstract method into non-abstract to check if the student satisfies the common graduation conditions. public void enroll(Course course) // Tries to enroll the course, do some checks before enrolling. public void recordGrade(Course course, Grade grade)// Records the grade of a course that is current learning. public double getGpa() // Calculates the GPA for this student. public UndergraduateStudent(Integer id, String name)// constructor public boolean canGraduate() //Additional graduating conditions for undergraduate students public PostgraduateStudent(Integer id, String name)// constructor public boolean canGraduate() //Additional graduating conditions for postgraduate students

2023-06-02 上传