Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART#1 - Rabbits or Carrots Game In this PART#I, you are NOT ALLOWED TO USE ARRAYS. You can only use variables (including String) to store

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
PART\#1 - Rabbits or Carrots Game In this PART\#I, you are NOT ALLOWED TO USE ARRAYS. You can only use variables (including String) to store data, selection statements (if, else-if, switch), while/for/do-while loops, and methods. You are not allowed to use other complex data structures (including arrays and ArrayLists), or classes to implement PART#1. You will implement this part in a java file called RabbitGamePart1.java. In this project, you will design and implement a game in which we have rabbits and carrots in a triangular game area. The user gives the size of the game area - S-. Let's assume that the user gives S as 6 . You will have a game area as follows: The user determines the size of the game area. It can be bigger or smaller. In the game area, you will have the following characters and rules; - Place 3 rabbits at random locations, - Place carrots at locations where i and j are both even numbers, - Place 2 rats at random locations, - Place 2 exit rooms at random locations (one goes to Heaven, the other goes to Hell, - Place one player in a random location. COMP1111 / FALL23 PROJECT 2 and 3 DEADLINE: 11.01 .2024 The player of the game can move in any direction (user inputs for moving are 8: up, 2: down, 6: right, 4: left depending on his current position, For example, if the player is at location (4,1), he can move to the right and down, but not move to the left and up. At the beginning of the game, the player has no carrots. When he visits a location having a carrot, his carrot count increases if he can answer an arithmetic question (addition, subtraction, division, multiplication) correctly. A question will be randomly generated. When the player visits a location having a rabbit, he feeds the rabbit with carrots. Each rabbit eats a random number of carrots. If the player has enough carrots, he gains some game points; otherwise, he loses some game points. When the player visits a location having a rat, he loses some of his carrots. You can determine the amount of points to lose/gain and the amount of carrots to lose by yourself. The game finishes when the player enters one of the exit rooms. If he enters the "Heaven Exit", print his total game points. If he enters the "Hell Exit", he will lose all carrots and lose the game. After each move as the output, print the current location of the player, the current number of carrots, the number of rabbits visited since the beginning of the game, total game points, etc. At the end of the game, print the game area showing rabbits, rats, carrots, exits, etc. Also, you MUST add any other game rules or special characters into your game. Your solution must be modular since you must define sub-tasks and implement methods. You have to write the following basic methods in your program and use them. You must also write other methods that you design. - is ThereARabit (int il, int j1, int i2, int j2, int i3, int j3, int i plager, int jplog) that gets the rabbit locations and the player's location and returns true if there is a rabbit at the player's location. - is ThereARat(int it, int j1, int i2, int j2, int i plage, int j plager) that gets the rat locations and player's location and returns true if there is a rat at the player's location. - isThineACarnol(int i ployer, int jplayer) that gets the player's location and returns true if there are some carrots at the player's location. - cxilToHeacen(int it, int j1, int i plages int j plajer) that gets the location of the Heaven Exit and the player's location and returns true if the player is at the Heaven Exit. Page 2 of 4 - evitToHell(int il, int j1, int i ploge, int j player) that gets the location of the Hell Exit and the player's location and returns true if the player is at the Hell Exit. - canMove(int i player, int j playes int diretion) that gets the location of the player and the direction he wants to go and returns true if it is possible to go in that direction (if there is a cell in that direction on the game area); otherwise returns false. - goneraleAQuestion(int bpe) that gets a number between 0 and 3(0; addition, 1: subtraction, 2: division, 3: multiplication) and asks the player a question of the given type, gets the answer, checks the answer and return true if the answer is true; otherwise false. - Other methods (at least 3 more) that you will design. PART\#2 - Advance Rabbits or Carrots Game Let's assume now in PART\#2 we have more than one player in the game area. There can be many players and each player will make his move in the game during his turn. You can use the array structure to store/ process the players. For game functionalities, you can call/invoke the methods that are implemented in the RabbitGamePart1.java dass, You can also change the number of rabbits, carrots, and rats in the game in this PART\#2, You will implement this part in a java file called RabbitGamePart2.java. At the end of the game, announce the player who wins the game. You must define a rule to determine the winner. You have to print some game statistics for each player at the end of the game. You must implement the following methods: - findWinna(...) that will return the winner of the game. - fundCarrotCollector(...) that will return the user who collects the most number of carrots. - findRabbitFeder(...) that will return the player who feeds the most number of rabbits. - fudRatVisitor(.....) that will return the player who visits the most number of rats. - Other methods (at least 2 more) that you will design. IMPORTANT RULES This is a strictly individual assignment. That means you are not allowed to take a peek at any solutions, including online resources, or AI tools such as ChatGPT, and you are not allowed to share your answers with anyone, including your classmates. You are not allowed to program together with your friends or relatives. You are only allowed to use your lecture notes and the textbook. Failure to follow these rules will result in getting only 1 point for the project. To validate your grade, you must present your project to your lab tutor on the date/hour that is determined for the project presentations, Projects without presentations will not be graded. Solve PART\#1 and upload your RabbitGamePart1.jaza file through Blackboard. Before solving PART\#2, first design your solution by drawing a flowchart. The flowchart should be drawn at the beginning before implementing the solution. Then, implement your solution for PART\#2 and upload your RabbitGamePart2_Flozchart file and RabbitGamePart2,java file through Blackboard. The neatness, and indentation of your code do matter. It should be clear and casy to read. You may lose points for non-commented code. Check the example figure below for a method call in a flozechart. The following flowchart shows how to call/invoke a method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago