Recent Changes · Search:

Functional Programming

Type Inference

Toss

  • (incorporates former Speagram)

Emacs

Kurs Pascala

Artificial General Intelligence

AI:

Algorithmic Game Theory: Prediction Markets (po polsku)

Programming in Java

kurs pracy w systemie Linux

Evolutionary Algorithms

Animation

Data Stores and Data Mining

Language Understanding

Systemy Inteligentnych Agentów

Przetwarzanie Języka Naturalnego

Programowanie Funkcjonalne

PmWiki

pmwiki.org

add user

edit SideBar

Primary course material:

See also:

Integrated Development Environments (Java and general):

Run Java code online:

Exercises:

  1. Due Oct 14: Self-Avoiding Walk Δ; Introduction to Programming in Java: SelfAvoidingWalk.java.
  2. Due Oct 21: Prime Factors Δ.
  3. Due Nov 4: Sets and Maps Δ.
    • ex3.jar Δ
      • DISCLAIMER: this example does not show the right way to implement containers or good programming practice, it is just an exercise in use and limitations of inheritance and interfaces.
    • ex3nested.jar Δ — example using nested classes.
    • Exercise update:
      1. implement the clone() method for MySetImpl and MyMapImpl;
      2. don’t forget to add simple demonstration tests for MySet.intersect, MyMap.union and clone() methods.
  4. Due Nov 18: Modify the nested Δ implementation of sets and maps (including the interfaces) to use generic types. (Some change to the class structure might be needed.) Remove the unnecessary class casts. Remember to fix all sources of so called unchecked warnings. To get the locations of warnings, compile with javac -Xlint:unchecked *.java. For bonus points, select one of the exercises:
    1. Add an iterator (or another form of browsing the elements) to the MySet interface. In union and intersect methods, use the instanceof operator to switch to a general way of performing these operations in case the argument is not of the MySetImpl class.
    2. Implement the Java standard library collection interfaces Set<E> and Map<K,V> using ordered linked lists, subclassing appropriate abstract classes from the library.
  5. Due Dec 2: Modify the simulation inspired by The Settlers game settlers.jar Δ in one of the following ways. (Select one exercise; the first four exercises are simple, the first three require little work.)
    1. Write a method to add a road segment between two existing waypoints.
    2. Add another kind of resources, for example STONE.
    3. Make the carriers return to the warehouse they came from after making a delivery, similarly to how they return when they cannot make the delivery; but in case they make the delivery to a warehouse where there is not enough carriers (e.g. less than 3), let them stay. Now, a small number of carriers should still distribute all resources needed.
    4. Add a terrain: a two-dimensional array of enum objects that decides which kinds of buildings can be built at which locations. (The terrain can be a field in the Scheduler class.)
    5. Add another kind of settler: a constructor, add an underConstruction boolean field to the Building class and modify notFunctional () to account for it. Modify the Building class so that the constructor settler needs to reside in a building for a time proportional to resourcesToBuild().sum() before underConstruction becomes false. Write a method in the Castle class that generates and schedules a task which searches for a building that is underConstruction but does not have a constructor, and sends a constructor there. The constructor should return back to the castle after finishing the job.
    6. Add another kind of building: sawmill, and another settler: woodcutter. The castle should send a woodcutter and a carrier to a sawmill after it is built. The woodcutter produces the wood and the carrier delivers it periodically to the nearest warehouse.
  6. Due Dec 9: Modify the simulation inspired by The Settlers game settlers.jar Δ in one of the following ways.
    1. Configure the simulation by reading a file.
    2. Modify the program to, instead of printing on the screen, pretty-print the output into a file. Generate a table with rows corresponding to successive time instances and columns corresponding to buildings and settlers. Create either a formatted text table, or an HTML table.
    3. Add functions to save the state of simulation into a file and restore it from a file, in binary. Hint: use serialization; don’t forget to make all and every class serializable (perhaps even turn the LookFor interface into a serializable abstract class).
  7. Due last week before the Christmas break, or if we cannot organize a class, on the first lab in 2012: either
    1. Write a graphical interface to display results of the Settlers simulation.
      1. For bonus points, extend it with a graphical interface to set-up the simulation.
      2. For bonus points, extend it with a stepping mechanism to display the course of the simulation as it evolves.
    2. Write a graphical interface to a project of your choice; you need to get the project accepted by Dec. 16.
  8. Concurrency. Select one of the following exercises.
    1. Write a program that downloads several pages from the internet and computes a joint histogram of words in the pages. Compare the performance when the pages are downloaded sequentially and concurrently.
    2. Rewrite the “Settlers” example from cooperative concurrency to fully using Java threads.
      • I will provide an almost-ready rewrite with only some bits to finish, stand by if you choose this exercise…
    3. Rewrite (parallelize) a project of your choice into using Java threads.
      • You need to get the project accepted on the first lab of January if you choose this exercise.
    4. Write a “Reminder” graphical application, managing messages to be displayed at scheduled times, perhaps periodically. Use ScheduledThreadPoolExecutor.

I will post the solution to the Settlers series of exercises in compiled form only not to spoil the fun, but if you’d rather develop new features than redo the assignments above, contact me, and I’ll share the sources.

Lectures:

  1. Lecture 1 Δ — Introduction to Java.
  2. Lecture 2 Δ — Classes, objects, inheritance.
  3. Lecture 3 Δ — Inheritance and interfaces. Nested types and inner classes.
  4. Lecture 4 Δ — Review: the Java tutorials.
  5. Lecture 5 Δ — Exceptions. Packages. Generating documentation with javadoc.
  6. Lecture 6 Δ — Covariance and Contravariance. Generics. Collections.
    1. Lec6.jar Δ — selected code examples from Thinking in Java by Bruce Eckel.
  7. Lecture 7 Δ — Input / Output.
    1. Lec7.jar Δ — selected code examples from Thinking in Java by Bruce Eckel.
  8. Graphical user interfaces: Swing, SWT. Event handling.
    1. Lec8.jar Δ — selected code examples from Thinking in Java by Bruce Eckel.
  9. Lecture 9 Δ — Concurrency.
    1. Lec9.jar Δ — selected code examples from Thinking in Java by Bruce Eckel.
  10. Lecture 10 Δ — Model-View-Controller pattern for Swing applications.
    1. Lec10.jar Δ — comprehensive example from Head First design patterns By Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates.
  11. Lecture 11 Δ — Usable, secure and maintainable code: Effective Java by Joshua Bloch.
Edit · History · Print · Recent Changes · Search · Links
Page last modified on January 12, 2012, at 04:37 PM