1 write a recursive instance method called

Assignment Help JAVA Programming
Reference no: EM13346699

(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: EM13346699

Questions Cloud

1 write a short technical report on one of the subsequent : 1. write a short technical report on one of the subsequent digital communication techniques-a. frequency division
Create the main window shown here you may use any layout : create the main window shown here. you may use any layout manager or you may lay the components out manually.when a
You are required to investigate the dynamic movement of a : you are required to investigate the dynamic movement of a mass m sliding along a rod as shown in the diagram below. the
A magnetic field is present in space and is time dependent : a magnetic field is present in space and is time dependent. it is given bybt sint i 7-t j 23t ka wire in the shape
1 write a recursive instance method called : 1 write a recursive instance method called countconnectedpipesint row int col. the method must not contain any loops
Question-if start with 93 gr of li how may grams of h2 can : question-if start with 9.3 gr of li how may grams of h2 can you make?nbspli h20 ----gt lioh h2if it starts with 3.4
Question 1imagine that a sample of 400 rental units shows : question 1imagine that a sample of 400 rental units shows thati the distribution of rents paid per month is not
1 what is the advantage of corrosion resistance : 1 what is the advantage of corrosion resistance biomaterials? discuss their properties. use example.2 where we can use
The use of pcr and genetic approaches in biotechnology1 : the use of pcr and genetic approaches in biotechnology1 define the following terms.a ecotillingb an allelic seriesc

Reviews

Write a Review

JAVA Programming Questions & Answers

  Temporarily move to the street so that the

Driveway is a "last-in, first-out" stack. Of course, when a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave

  Program that allows the user to enter the last names

Write a program that allows the user to enter the last names of 5 candidates in a college election and the votes received by each candidate. The program should then output each candidates name, the votes reveived by that candidate

  Design a program that extends the definition of the class

Design a program that extends the definition of the class JFrame to display a window on the screen. Name your class PropertyTax1, title your window "Calculation of Property Taxes," set the window's width to 400 pixels and height to 300 pixels, and te..

  Concept of web based information system

Design and implement a simple and small email server using the concept of web based information system

  How to detect the correct ip address and run it locally

When you compile the two modules, with disabling the package statement, it runs on one single machine, that's running the server

  Product maintenance with a database

Use a class named ProductDB that's in the music.data package to add, update, and delete the products in the Product Maintenance application.

  Fixing errors in a java program

You coded the following on line ten of the class MyApplet.java:

  Implementation of encryption and steganography in java

This is a project report showing the essential details and coding structures related with the implementation of encryption techniques and steganography in JAVA.

  Design java program to enter name in input dialog box

Design the program called MailingLabel.java Program must ask user to enter name and address in input dialog box with each component of address seperated by comma.

  Create a deque class based on the discussion of deques

Create a Deque class based on the discussion of deques (double-ended queues) in this chapter. It should include insertLeft(), insertRight(), removeLeft(), removeRight(), isEmpty(), and isFull() methods.

  Develop a gui based java program

Designing and developing a College Registration program

  Write a reference class called ctatrain

writing a reference class that consist of the 2nd and 3rd instance variables below. my class should consist of an array of values in the 2nd instance variable

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