Write a recursive instance method

Assignment Help JAVA Programming
Reference no: EM13594

(1) Write a recursive instance method called countConnectedPipes(int row, int col). The method must not contain any loops and must be directly recursive (i.e., no indirect recursion). This method will be called from your user interface with the row and col being set to the row and column of the valve pipe placed on the grid. It should count and return the number of pipes that have been successfully connected to the valve pipe. Any pipes not connected to the main valve "chain" of pipes should not be counted. For example, the picture here shows 24 placed pipes and the picture on the right shows the 14 pipes (as enabled buttons) that are connected to the valve (including the valve) and the 10 pipes (disabled buttons) that are not connected. You will need to ensure that your pipes are initially unmarked. which you should do with a different method (in which may use a FOR loop to run through the array and reset things accordingly).

172_Write a recursive instance method.png

(2) Write a recursive instance method in the PipeGame class called countOpenEnds(row, col) which takes the valve location as a parameter (just like the countConnectedPipes method) and returns the integer count of open ends. As with your other method, this method must NOT use indirect recursion. The example above has 6 open ends.

(3) Adjust your PipeGameApp code so that the score is calculated as 10 times the number of connected pipes minus 5 times the number of open ends. You MUST calculate this value using your recursive methods. The example above would give a score of (14*10) - (6*5) = (140-30) = 110.

(4) Adjust your PipeGameApp code so that when the game is completed, you should also disable all buttons that do not have pipes connected to the valve (as shown in the picture here). Also, add a JLabel to your user interface (placed nicely of course) saying "Open Ends: xxx" which displays the number of open ends of pipes that are connected to the valve. The number of open ends should be displayed continuously while the game is running (i.e., after every pipe piece is placed), not just when the game has stopped.

1279_Write a recursive instance method1.png

Reference no: EM13594

Questions Cloud

Frequency division multiplexing : Write a short technical report on Frequency Division Multiplexing
Create a window in java : Create a window apllication in java
Investigating a dynamic movement in polar coordinates : Investigating A Dynamic Movement in Polar Coordinates
What is the magnitude of the current in the wire : What is the magnitude of the current in the wire as a function of time?
Write a recursive instance method : Write a recursive instance method
How many mols of hydrogen can produce : how many mols of H 2 can produce
Calculate the probability : Calculate the probability that the rent of a randomly selected unit.
Advantage of corrosion resistance biomaterials : What is the advantage of Corrosion resistance biomaterials

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Develop a reliable transfer protocol over udp

Develop a reliable transfer protocol over UDP. Focus on a Stop- and-Wait protocol.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Determine if strings are equal

Complete the recursive method match in the code below which will determine whether or not two strings match.

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd