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.:- M9131054
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Java

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

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 ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

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 ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

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. ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 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