Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

(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

Java, Programming

  • Category:- Java
  • Reference No.:- M9716316
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Java

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As