Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Computer Laboratory – Course material 2010–11: Object-Oriented Programming Skip to content | Access key help Search Advanced search A–Z Contact us Computer Laboratory Computer Laboratory Teaching Course material 2010–11 Object-Oriented Programming Advanced Category Theory in Computer Science Advanced Computer Design Advanced Data Flow Analysis Advanced Graphics Advanced Speech Technology Advanced Topics in Computer Systems Advanced Topics in Concurrency Algorithms I Algorithms II An Algebraic Approach to Internet Routing Artificial Intelligence I Artificial Intelligence II Building an Internet Router Business Studies Categorical Logic Category Theory for Computer Science Chip Multiprocessors Comparative Architectures Compiler Construction Complexity Theory Computation Theory Computer Design Computer Fundamentals Computer Graphics and Image Processing Computer Networking Computer Systems Modelling Computer Vision Concepts in Programming Languages Concurrent and Distributed Systems I Concurrent and Distributed Systems II Data Centric Networking Databases Deep Language Modelling Denotational Semantics Denotational Semantics Digital Electronics Digital Signal Processing Discrete Mathematics I Discrete Mathematics II E-Commerce ECAD Labs Economics and Law Floating-Point Computation Flows in Networks Foundations of Computer Science Further Java Further Java Briefing Hardware Practical Classes Hoare Logic Human-Computer Interaction Information Retrieval Innovative user interfaces Interactive Formal Verification Introduction to Natural Language Processing Introductory Logic Lexical Semantics and Discourse Processing Logic and Proof Low Power Embedded Systems Programming Machine Learning for Language Processing Mathematical Methods for Computer Science Mobile and Sensor Systems Multicore Programming Natural Language Processing Network Architecture Object-Oriented Programming Information for supervisors Operating Systems Optimising Compilers Principles of Communication Probability Programming Logics and Software Verification Programming for Mobiles Programming in C and C++ Programming in Java Prolog Registration Regular Languages and Finite Automata Research Methods Current Research Topics Security I Security II Semantics of Programming Languages Set Theory for Computer Science Social and Technological Network Analysis Software Design Software Engineering Spoken Language Processing Statistical Machine Translation Syntax and Semantics of Natural Language System on Chip Design and Modelling System-on-Chip Design Temporal Logic and Model Checking Topical Issues Topics in Concurrency Topics in Logic and Complexity Topics in Security: Forensic Signal Analysis Types Unix Tools Usability of Programming Languages Course material 2010–11 Object-Oriented Programming Principal lecturer: Dr Robert Harle Taken by: Part IA CST, Part IA NST, Part I PPS Syllabus Past exam questions Information for supervisors (contact lecturer for access permission) Introduction This web page is here to support the IA OOP course, which ran in Lent 2011. The course was an attempt to formalise some of the notions students have been exposed to in the Java ticks. It was intended to complement those practicals, but will stand up on its own for anyone not doing the CST paper 1 course. Handout/Notes The handout provided in lecture one is available here. Errata: p. 6: "declaritive" should be "declarative" p. 7 slide: "...understanding computer and computers" -> "...understanding computation and computers" p.15 top para: "Looking back oat..." -> "Looking back at..." p. 21 last para: "...are a plenty..." -> "are plenty" p. 24 first para:"...I think this is rather confusing area for Java" -> "...I think this is a rather..." p. 24 second para: The variable names got mixed up. It should have said: "The operating system allocates another int somewhere in memory (called i)and copies the value of the original (i=test_i). All subsequent operations in the procedure occur on the copy (i), which is then deleted at the end of the procedure." p. 25 second para: "...see that really passes..." -> "...see that Java really passes.. ." p.85 top para: "...compare the references of the objects..." should be "...compare the references or the objects..." p.86 slide example: I think it's a bit misleading to use the String class as an example of overriding the equals method (since the == operator compares values for Strings but compares references for any other Object even if the equals method is overridden) -- after seeing this String example, the students may be expecting that p1 == p2 will work as long as the equals method of Person is overridden, but in truth, p1==p2 will still fail but p1.equals(p2) will work p.89 slide: "...then creates and InputStream for it" -> "...then creates an InputStream for it" p.94 top para: "You might that find they don't..." -> "You might find that they don't..."\ p.129 State definition: "Allow and object to..." -> "Allow an object to..." p.129 Strategy definition: "...encapsulate each on..." -> "encapsulate each one..." p.129 Composite definition: "...and compositions of objecta uniformly" -> "...and compositions of objects uniformly" p.130 last para: "...if there even s a 'right'" -> "...if there even is a 'right'" The general Abstract factory Pattern in the notes is wrong. The correct version is found in the lecture 9 annotated notes or in any design patterns book. Progress Lecture 1: Review of fetch-execute, pointers, references, Java VM (annotated slides) Lecture 2: Argument passing, modularity, encapsulation (annotated slides) Lecture 3: Bouncing ball example, inheritance, field shadowing (annotated slides). The bouncing ball code is available here. Unzip the file and then run java uk.ac.cam.cl.rkh23.BouncingBall.Simulation or java uk.ac.cam.cl.rkh23.BouncingBall.Simulation2 for lots of balls :-). Lecture 4: Polymorphic functions, shape drawing example, abstract classes, interfaces. (annotated slides). The shape drawing code (all 3 versions) is available here. Unzip the file and then run java uk.ac.cam.cl.rkh23.ShapesOption1.DrawingWindow to view it. Alternatively substitute ShapesOption1 with ShapesOption2 or ShapesOption3 to play with those options. Lecture 5: Constructors, destructors, Class level data, exceptions annotated slides) Lecture 6: Cloning, Java class libraries, Collections (annotated slides). The cloning example I used in lectures can be found here Lecture 7: Generics, comparing objects (annotated slides). The small examples I used in lectures can be found here Lecture 8: Design Patterns: Decorator, State, Strategy, Composite, Singleton (annotated slides). The example Java code for the design patterns is available here. Lecture 9: Design Patterns: Proxy, Observer, Abstract factory (annotated slides). Additionally the Java Puzzlers slides can be downloaded here. All Source code I have cherry picked code examples above, but if you really want all of the code I used or prodcued in lectures, look here. No warranties or guarantees that it was left in the optimal state - this is a copy of what was on my laptop after each lecture! Examples Sheet The examples sheet for the course can be downloaded here. Errata: Q7. The question defines a function double(...), but "double" is a restricted word in java, so you can't compile it. It doesn't change the point of the question but it should have been dbl(...). Q11. For some reason the code skips between calling the Wheel member "radius" and "rimSize". Pick one and change everything else to use it! Sample Tripos Questions I have started to produce a few sample exam questions for the course since it's a recent addition to the IA CST lineup. Update 27/04/11: I have clarified Sample 1 and made solutions available: Sample Tripos 1 and its solution Sample Tripos 2 and its solution At the end of the course I will put up the solutions to these samples. Eclipse When I write Java code in lectures I will tend to use Eclipse. This is a free program called and you can download it from here. You can download various add-ons to support different programming languages, but if you download and install the "Eclipse IDE for Java Developers" you should find that has everything you need to write and test Java programs. If you're wondering why we don't use it in the ticks, it's because we're trying to do two things: i) teach you Java, and ii) make you familiar with UNIX (which is very popular, especially in scientific circles). The eclipse platform is great, but it masks away the UNIX stuff and can be quite bewildering. Once you're proficient in Java, using a tool like Eclipse is highly recommended. But for now, stick to UNIX for the coursework. If you're looking for a way to do your ticks from home, you can download the Java tools (compiler, virtual machine, etc) here. Alternatively you can login to the PWF from your room (see here and here for details. © 2011 Computer Laboratory, University of Cambridge Information provided by Dr Robert Harle