Fern   davin.50webs.com
New Zealanders making it harder to hate computers

       Main Menu        Research Projects       Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address     Computer Games        Web Design           Java Programming       The Fly (A Story)   
  Political Activism   Bob Dylan Quotes+       My Life Story          Smoking Cessation          Other Links      


S.J.S. tutorial 12: more questions about references

SECTION(12, Tutorial 12) m5_question(BO(Question 12.1:) Write constructors for the classes CLSS(SportsShoe) and CLSS(Runner) below, by looking at the MAIN function to see how many arguments each constructor has. m4_begin_indent NU()m4_include(sjs-tutorials/RunnerTest.m4) m4_end_indent ) m5_question(BO(Question 12.2:) In the CLSS(Runner) class, write the private method TT(computeSpeed) that has no arguments and returns a double-precision floating point value that equals the runner's running speed. Note that the speed of a runner is determined by multiplying their TT(speed) property with the TT(speedBoost) property of the shoes that they are wearing. For example, Speedy Gonzalez's running speed = 55 * 2.0 = 110.0.) m5_question(BO(Question 12.3:) Fix the TT(race) method so that it checks for a draw.) m5_question(BO(Question 12.4:) By copying the TT(race) method, write a three-parameter TT(race) method for racing three runners against each other. Two methods in the same class with the same name is called EM(overloading) in Java. Add a call to this method from the MAIN function.) m5_question(BO(Question 12.5:) What is the difference between a method and a function? Write a one parameter method TT(raceAgainst) that behaves exactly like two-parameter function TT(race). There are two ways of doing this, one is to optionally use the THIS keyword rather than one of the parameters TT(r1) or TT(r2). The second way is for TT(race) to simply call TT(race) using THIS as one the the arguments to the function.) m5_question(BO(Question 12.6:) Is it true that any method can be re-worked into a function and vice versa?) m5_question(BO(Question 12.7:) The TT(swapShoes) method in the CLSS(Runner) class swaps the shoes of two runners. Add some code to the MAIN function to swap the shoes of two runners and verify that the shoes do indeed get swapped.) m5_question(BO(Question 12.8:) Write a method called TT(swapNames) that swaps the names of two runners. You can put this function into any class but it makes the most sense to put it into the CLSS(Runner) class since it has two CLSS(Runner) parameters.) m5_question(BO(Question 12.9:) Write a method TT(swapSpeeds) that swaps the TT(speed) properties of two runners.)
Back to Main Menu
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Programming | The Fly (A Story) |
| Political Activism | Bob Dylan Quotes+ | My Life Story | Smoking Cessation | Other Links |

Please report any broken links to the Web-person
Last modified: Tue Mar 25 12:26:58 NZST 2014
Best viewed at 800x600 or above resolution.
© Copyright 1999-2014 Davin Pearson.