Reference no: EM132471650
COSC2531 - Programming Fundamentals - RMIT University
Overview
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 may be awarded partial marks for explaining a valid strategy, even if the program is not working.
Develop this assignment in an iterative fashion (as opposed to completing it in one sitting). You can and should get started now as there are concepts from the week 1 lessons that you can incorporate from now itself.
Assessment Criteria
This assessment will determine your ability to:
1. Follow coding, convention and behavioral requirements provided in this document and in the lessons.
2. Independently solve a problem by using programming concepts taught over the first several weeks of the course.
3. Write and debug Java code independently.
4. Document code.
5. Ability to provide references where due.
6. Meeting deadlines.
7. Seeking clarification from your "supervisor" (instructor) when needed via discussion forums.
8. Create a program by recalling concepts taught in class, understanding and applying concepts relevant to solution, analysing components of the problem, evaluating different approaches.
Learning Outcomes
LO 1. Demonstrate knowledge of basic concepts, syntax and control structures in programming
LO 2. Devise solutions to simple computing problems under specific requirements
LO 3. Encode the devised solutions into computer programs and test the programs on a computer
LO 4. Demonstrate understanding of standard coding conventions and ethical considerations in programming.
Assessment details
MyBlock is a simple tool which can help one design a block of land. Your task is to write a Java program that implements the design functionality, checks if all the rules are followed, displays the block. The basic structure of the code is provided in the Canvas shell. You need to complete the following tasks. Please use the skeleton code provided to complete your code.
Your program should consist of a MyBlock class. The class has a two dimensional array of integers called block. The class also has a Boolean variable vacant that stores the information of whether the block of land is vacant or not. The methods of this class are: displayBlock(), addHouse(), and clearBlock().
Assessment Task A
The constructor of the MyBlock class takes 2 parameters: the number of rows of the block, the number of columns of the block. In the constructor of this class, write code to initialize the block with the size of row and column. Initialize each value of the array block with the value 0, which means that block is unused. Initialize the value of vacant to true.
Assessment Task B
Write a method of the MyBlock class called displayBlock() that prints the block 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 displayBlock() is shown below, for a vacant block of 4 x 3.
0 0 0 0
0 0 0 0
0 0 0 0
Assessment Task C
Write a method of the MyBlock class called clearBlock()that sets the value of each element of the array ‘block' to zero (0). Set the value of vacant to true.
Assessment Task D
From the main method, the user can enter the row and column of the block. The number of rows and the number of columns should be an integer greater than 2 and less than or equal to 10. If any input is incorrect, show an error message and ask for that input again. If all inputs are correct, create an object of MyBlock class from main method. The row and column values are passed as the parameter of its constructor.
Assessment Task E
From the main method, show a menu to the user with the following options. If the input is neither 1,2,3,4, show an error message and ask the user for input again.
1. Add a house
2. Display the block
3. Clear the block
4. Quit
Assessment Task F
Implements the addHouse() method that takes four input parameters: the row position, the column position, the number of rows, and the number of columns of the house. Parameters row position and column position are the house's top left corner position. For example (2, 1) means the house starts from 2 rows down from the top and 1 column from the left edge of the block.
Attachment:- Programming Fundamentals.rar