Develop your programming and problem solving skills

Assignment Help Other Subject
Reference no: EM131944090

Assignment

Introduction
You must demonstrate your assignment in your timetabled practical class prior to your final submission.

Objective
The objective of this assignment is to develop your programming and problem solving skills in a step-by-step manner. The different stages of this assignment are designed to gradually introduce different concepts, such as loops, arrays, and methods.

Students will be awarded partial marks for explaining a valid strategy, even if the program is not working.

Assessment
Demonstration: The demonstration is worth 10% of the final grade (half of the weight of Assignment 1). The whole assignment group must be present to demonstrate the assignment in a timetabled practical class (tute-lab) prior to the final submission. If members come from different classes, please choose just one of the classes to make the demonstration. Subject to on-time final submission and plagiarism detection, you will receive the preliminary marks for your demonstration. The code should be clean and have proper comments. You can choose to demonstrate either during week 6 or week 7 tute-lab, but you can do it just once.

Assessment tasks

Your program should consist of a LandVille class that contains the main method. The class has a two dimensional array of integers called ‘land'. The ‘land' variable should not be accessible outside the class. The class also has a Boolean variable ‘hasHouse' that stores the information of whether is an existing house in the land. The methods of this class are: displayLand(),buildHouse(), and clearLand().

Task A

The constructor of the LandVille class takes 2 parameters: the number of rows of the land, the number of columns of the land. In the constructor of this class, write code to initialize land with the size of row and column. Initialize each value of the array ‘land' with the value 0, which means that plot is empty. Initialize the value of ‘hasHouse' to false.

Task B

Write a method of the LandVille class called ‘displayLand()' that prints the land as a two dimensional array. Give a space between each element during printing, and use a line for each row. An example of the output of displayLand() is in the following, where the number of rows is 3 and columns is 4.

2403_Output.jpg

Task C

Write a method of the LandVille class called ‘clearLand()' that sets the value of each element of the array ‘land' to zero (0). Set the value of ‘hasHouse' to false.

Task D

From the main method, ask the player for the row and column of the land. The number of rows and the number of columns should be greater than 0 and less than or equal to 10. If any input is not correct, show an error message and ask for that input again.

If all inputs are correct, create an object of LandVille class from main method. The row and column values are passed as the parameter of its constructor.

Task E

From the main method, show a menu to the user with the following options:
1. Build a house
2. Display land
3. Clear the land
4. Quit

Take the input option as an integer. As long as the input is not between 1 to 4, show the menu message and ask for input again. If the input is 4, terminate the program. If the input is 2, you need to call the displayLand() method of LandVille class (displayLand method is described in Task B). If the input is 3, call the clearLand() of LandVille class.

If the input is 1, you need to check first if there is already a house in the land. If there is a house, show an error message and show the menu again. Otherwise, call the buildHouse() method of LandVille class. Method buildHouse() of the LandVille class takes two input parameters: number of rows of the house to build, and the number of columns of the house to build. From the main method, ask for these parameter values as input, then call the buildHouse method with these inputs.

After the buildHouse is executed (details in task E), the program should keep showing the menu and ask for input from the menu.

Task F

Write a method buildHouse() of the LandVille class that takes two input parameters: number of rows of the house to build, and the number of columns of the house to build.

You need to build the house at the top-left corner of the land (i.e., from row 0 and column 0), with borders of width 1 on each side. The position of house is represented with the integer ‘8' and the border is represented with ‘1'.

To make sure that the house with the border on each side will fit in the land, the difference between the row of the house and the row of that land must be greater than or equal to 2. Similarly, the difference between the column of the house and the column of that land must also be greater than or equal to 2. If any of the input parameters do not satisfy the condition, show an error message and then return from this method. As an example, let the row number of a land is 7 and column number is 6. The row number of the house is 3 and column number is 5. In this case, do not make any change to the ‘land' array, show an error message, and return from the buildHouse method.

If all the input parameters satisfy the condition, you need to set the values of appropriate elements of the ‘land' array with ‘1' for border and ‘8' for the house. As an example, let the row number of a land is 7 and column number is 6. The row number of the house is 3 and column number is 2. The land array will look like the following -

2294_Output1.jpg

As another example, let the row number of a land is 5 and column number is 4. The row number of the house is 1 and column number is 2. The land array will look like the following

1762_Output2.jpg

Write code of buildHouse method to change the value of the array ‘land' for the house and border. Set the value of ‘hasHouse' to True. After building the house, call displayLand() from the buildHouse method.

Attachment:- LandVille.zip

Verified Expert

The solution file is prepared in netbeans and implemented landville project which has build land , display land and clear land method. Each method performing different operations. Here i have attached report on this project which explain coding with screen shot and also i have attached LAndville.java file with comments for all lines of the coding

Reference no: EM131944090

Questions Cloud

Respond to the post in one or more ways : Respond to the post below attached in file in one or more of the following ways: Share an insight from having read your fellow learners' postings.
What trade barriers were in place during that decade : What are the main goods and services the United States traded internationally? What trade barriers were in place during that decade?
What are the different types of memories : What are the different types of memories presented in your readings this week? What information or process is each type of memory responsible for?
Propose how to resolve the dispute : Point out the differences and propose how to resolve the dispute.
Develop your programming and problem solving skills : COSC2531 Programming Fundamentals - Write a method of the LandVille class called ‘clearLand()' that sets the value of each element of the array ‘land' to zero
How will this acceptance of fake news impact our democracy : Is "fake news" really all that recent, or do we hear more about it as a result of the recent election cycle and events that have followed?
Similarities and differences of legal drugs : Compare and contrast the similarities and differences of legal drugs, particularly caffeine, alcohol, and nicotine to illegal/prescription drugs.
Calculate the average inventory and inventory turnover rate : Calculate the Average inventory, Inventory turnover rate, Average account receivable, Account receivable turnover and Average collection cycle.
An evidence of sexism in american culture : While there are no official rules that are different between male and female political candidates, they are viewed differently and females have more barriers.

Reviews

Write a Review

Other Subject Questions & Answers

  Describe the research on metacompregension skills

Describe the research on metacompregension skills. How could you apply these strategies to improve your own reading skills for a course other than cognitive psychology?

  Theories of morality application morality

Analysis of the three theories of morality Application Morality and Social Responsibility Philosophical perspectives and theories on morality contribute to an understanding of the deep

  An emergency management and its importance to communities

discussed Emergency Management and its importance to the local communities as well as, state and federal officials

  What issues should law enforcement personnel receive

What issues, plans, steps, and training should law enforcement/front-line personnel receive/utilize regarding crisis intervention?

  Analyze the membership of the somali pirate groups

Analyze the membership of the Somali pirate groups and their leadership. How are they structured. What is their motivation for belonging to the group

  Compare the various roles officer marconi must play

Analyze how a law enforcement officer's actions might be influenced if he or she is arresting an "unsympathetic suspect or victim," specifically a suspect or victim who the officer has arrested before or who engages in a high-risk lifestyle, such ..

  Was the employer discharge of drake and keeler

Was the employer's s discharge of Drake and Keeler ran unfair labor practice under the LMRA, as amended? If so, what should be the appropriate remedy

  Explain the role of us secret service asac

Consider all sides (the pros and cons) associated with the purchase of the drone aircraft.

  Many specific comparisons and contrasts as possible

Choose two of the following 19th century American groups, describing Both what they had in common and what was unique (comparisons and contrasts) in the conditions under which they lived, being sure to make as many specific comparisons and contrasts ..

  Calculate the final linear velocity

Calculate the final linear velocity (in m/s) of the person, given his mass is 83.0 kg.

  Explain why you believe this is racial discrimination

Franklin hears about people being discriminated against at the workplace and in society but rarely experiences it first hand. Cortez, on the other hand, speaks English poorly and is often subject to derogatory comments from peers and coworkers.

  Question 1a name the two main types of industrial

question 1a name the two main types of industrial ventilation used to control air contaminants in a work environmentb

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