Assignment 5, due Feb 19
Part of
the homework for CS:2820, Spring 2016
|
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!
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)
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?
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)