Results 1 to 6 of 6
Thread: i need help with assignment
- 11-27-2012, 07:41 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
i need help with assignment
Objective of the assignment
The objective of the assignment is to develop your understanding of how to use two-dimensional arrays in a practical problem.
Assignment
Topic of assignment: Simulated vacuum cleaner
Write a program for an intelligent vacuum cleaner. Given a rectangular room with a square obstacle in the center, please write a program that can navigate the cleaner to move around and clean the entire room in a straight line pattern.
The project will be used as a base of sequential projects in this class. You will have related projects in the File/Image class, and GUI programming.
Problem representation:
Room: represented with two-dimensional array of known size
Space: represent with pixels or array elements
Obstacle: side length is known and pixels are represented with a specific value
Problem analysis
You will design a main method and a clean method. Please be reminded that a vacuum CANNOT jump over an obstacle.
main method: get inputs from the console; create an initial room map
clean method: produce output which include a navigation signal sent to the moving part and a clean signal sent to the cleaning part (simulate them by printing texts on the console)
Input: room size, and obstacle location
Output: a sequence of cleaning path
A running example:
Room size: 5 7
Obstacle’s start position: 3 3
Obstacle’s side length: 2
Clean; Move to right
Clean, Move to right
Clean, Move to right
Clean, Move to right
Clean, Move to right
Clean, Move to right
Clean, Move down
Clean, Move left
…….
Outcome
This is extra credit that i really need to pass this class
- 11-27-2012, 08:08 AM #2
Re: i need help with assignment
If your capabilities are limited to dumping your assignment on a public forum, do you think you deserve to pass?
Recommended reading: How to ask questions the smart way
Post your best efforts and indicate where you're stuck and you'll surely get help.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 11-27-2012, 08:09 AM #3
Senior Member
- Join Date
- Nov 2012
- Posts
- 105
- Rep Power
- 0
Re: i need help with assignment
This forum doesn't do your work for you. The moderators will probably tell you the same thing.
- 11-27-2012, 10:28 AM #4
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Re: i need help with assignment
can you send your request to <email address removed to protect the innocent -mod>
Last edited by JosAH; 11-27-2012 at 10:35 AM.
- 12-04-2012, 12:24 AM #5
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
Re: i need help with assignment
Run and compiles fine, just want someones opinion before i submit.
import java.util.Scanner;
public class Vacuum{
public static void main(String[] args) {
//Create a Scanner
Scanner input = new Scanner(System.in);
int k1;// a
int k2;// b
int k3;
int k4;
int k5;
System.out.println("Please enter a width"); // prompt
k1 = input.nextInt();// reads first input
System.out.println("Please enter a length"); // prompt
k2 = input.nextInt();// reads second input
System.out.println("Please enter the row location of the obstacle");
k3 = input.nextInt();
System.out.println("Please enter the column location of the obstacle");
k4 = input.nextInt();
System.out.println("Please enter the size of the obstacle");
k5 = input.nextInt();
//Input usage scanner
int r = k1;
int c = k2;
int s = k3;
int y = k4;
int a = k5;
//Create a matrix
int[][] room = new int[k1][k2];
//Create a way for the vacuum to move around
for (int row = 0; row < room.length; row++) {
for (int col = 0; col < room[row].length; col++){
if (row >= col) {
if (col <= room.length)
System.out.println("Clean, move to the right");
}
else if (col == room.length - 1)
System.out.println("Clean, move up");
else if (row <= col)
System.out.println("Clean, move left");
if (row == col){
System.out.println("Clean, move down");
}
}
}
}
}
- 12-04-2012, 03:32 AM #6
Re: i need help with assignment
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Help with assignment
By mehnihma in forum New To JavaReplies: 1Last Post: 09-18-2011, 03:06 AM -
I need help with an assignment
By newarcher in forum New To JavaReplies: 12Last Post: 09-08-2011, 01:09 PM -
Need Help with assignment - Willing to Pay!
By BlackBalloon in forum NetBeansReplies: 2Last Post: 08-29-2011, 05:04 AM -
Need help with a HW assignment
By mackavelirip in forum New To JavaReplies: 4Last Post: 02-17-2011, 01:36 AM -
Assignment
By shinkymar in forum New To JavaReplies: 2Last Post: 03-06-2010, 01:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks