Assignment 5, due Feb 19

Part of the homework for CS:2820, Spring 2016
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of lecture on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

  1. Background: Look at the example code distributed with the Feb. 12 lecture. There are several bug notices that ask what happens if there is no next token. For example, after the assginment to sourceName in the initializer for class Road.

    a) What happens. This is a scavenger hunt question best answered by an internet search to find the relevant Java documentation. (0.4 points)

    b) Suppose you wanted missing identifiers to default to the string "---". Write code to replace the initialization of sourceName that does this. (0.6 points)

  2. Background: There are bug notices in the code that ask "should we prevent creation of this object" in cases where the object is so malformed that it might not make sense to create it.

    a) How can a Java object constructor exit in such a way that no object is created and returned? (0.5 points)

    b) Suppose you wanted the code that constructs the object to return null as a signal that no object was constructed. A constructor cannot return null, so you would have to replace calls to new Neuron() with calls to the method named newNeuron(). How can you allow code within the newNeuron() method to use the default constructor for class Neuron without allowing outside code to call that constructor?

  3. Background: Our model of a neuron based on a model proposed by McCulloch and Pitts in 1943, with minor enhancements to reflect the basic biology of neurons. In our model, the two basic types of synapse, excitatory and inhibitory, have been distinguished by just one thing, the sign of the synaptic strength. Excitatory synapses send positive signals, inhibitory synapses send negative signals. This is a gross oversimplification of reality.

    In fact, there are fast excitatory synapses, slow excitatory synapses, fast inhibitory synapses, and slow inhibitory synapses, each involving different neurotransmitters (the chemicals that actually convey the message across the synaptic gap). Furthermore, there is also a special kind of synapse (we'll call it a secondary synapse). Where primary synapses connect axons to the cell body of a different neuron, secondary synapses connect axons to other (primary) synapses. When a secondary synapse fires, it decreases the strength of the primary synapse to which it is connected.

    A question: How could you use polymorphism in a Java neuron-network simulator in order to account for these differnces. Specifically, what class would be the parent class and what would be the appropriate subclasses needed to incorporate the new information presented above. (1 point)