Java Main task: given a chess piece and its initial position (x, y), verify that you can
Fantastic news! We've Found the answer you've been seeking!
Question:
Java
Transcribed Image Text:
Main task: given a chess piece and its initial position (x, y), verify that you can move it to the new position. The program should write "Piece_Name at X, Y can move to X+1, Y" or "Piece_Name at X, Y can NOT move to X+1, Y". For example, "Queen at D, 1 can move to E, 1. When verifying the move, check that initial and final positions are inside the chess board, new position is possible based on the rules for that piece and consider that the chess board only has that piece. You are given a text file with several chess pieces. Number of pieces, types of pieces, and the order of the pieces may change every time you read a file. Each row in the file includes piece_name, color, pos X, and pos_Y. You must write a program to verify the movement of each chess piece in the given file. You must read values from the file, create an object/structure for each piece, allocate all the pieces in an array, prompt the user for the new position, and transverse the array verifying a move for each piece with the new position. You should print the verification result for each piece. Chess additional information. A chess board contains 8 by 8 boxes which are potential places for the chess pieces. There are six different pieces: Pawn, Rook, Knight, Bishop, Queen, and King. Each piece has its own movement rules. Your task is to read some movements from a file and validate those ones. Main task: given a chess piece and its initial position (x, y), verify that you can move it to the new position. The program should write "Piece_Name at X, Y can move to X+1, Y" or "Piece_Name at X, Y can NOT move to X+1, Y". For example, "Queen at D, 1 can move to E, 1. When verifying the move, check that initial and final positions are inside the chess board, new position is possible based on the rules for that piece and consider that the chess board only has that piece. You are given a text file with several chess pieces. Number of pieces, types of pieces, and the order of the pieces may change every time you read a file. Each row in the file includes piece_name, color, pos X, and pos_Y. You must write a program to verify the movement of each chess piece in the given file. You must read values from the file, create an object/structure for each piece, allocate all the pieces in an array, prompt the user for the new position, and transverse the array verifying a move for each piece with the new position. You should print the verification result for each piece. Chess additional information. A chess board contains 8 by 8 boxes which are potential places for the chess pieces. There are six different pieces: Pawn, Rook, Knight, Bishop, Queen, and King. Each piece has its own movement rules. Your task is to read some movements from a file and validate those ones.
Expert Answer:
Answer rating: 100% (QA)
import javaioFile import javaioFileNotFoundException import javautilArrayList import javautilList import javautilScanner class ChessPiece private Stri... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these electrical engineering questions
-
Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. Design: James Gosling First appearance: May 23, 1995; 26 years...
-
Java Company earned net income of $85,000 during the year ended December 31, 2018. On December 15, Java declared the annual cash dividend on its 4% preferred stock (par value, $120,000) and a $0.25...
-
Java Hut leased a specialty expresso machine for a 10-year non-cancelable term. At the end of the 10-year term, Java Hut has four consecutive one-year renewal options. A replacement machine can be...
-
1-Kristen prefaces her speech by talking about her inability to save or invest money. For that reason, she does her speech on an online money management course and focuses on the skills she learned...
-
Last week Eduardo calculated the overall project ROR values for two alternatives A and B using the estimates below. He calculated iA* = 34.2% and iB* = 31.2% and recommended acceptance of A since its...
-
In Fig. 7-42(c), quantization noise occurs due to the use of 4-bit samples to represent nine signal values. The first sample, at 0, is exact, but the next few are not. What is the percent error for...
-
Two businesses are considering how to raise \(\$ 5\) million. Buchanan Corporation is having its best year since it began operations in 1998 . For each of the past 10 years, earnings per share have...
-
Pimental Manufacturing Inc. is the producer of specialty machinery for numerous customers. It had $10,000,000 of sales in 2016 and identified the following costs as being related to quality: Scrap...
-
Global Engineers hired the following number of engineers during the first six months of 2017. Assume the data represent a sample . (20 pts) Month Engineers Hired (x) January 3 February 2 March 4...
-
The block diagram of Fig. 1.b represents the heading control of the traditional bi-wing aircraft in Fig. 1.a. Aa Controller Engine dysunkc 100 10 Design a control system for the bi-wing aircraft to...
-
Bev Company sells heavy machinery. On October 1, Year 10, Bev sold goods in the amount of 850,000 ( is Pounds Sterling) to Basketsprint in the UK. Bev accepted a note receivable and payment is due...
-
Marvel Parts, Incorporated, manufactures auto accessories. One of the company's products is a set of seat covers that can be adjusted to fit nearly any small car. The company uses a standard cost...
-
A one cubic foot sample of a borrow-source clay weighed 88 lbs. If the specific gravity of solids was measured as 2.70, and the clay was found to be 10 percent saturated, determine the water content...
-
Compute the missing amount in the accounting equation for each entity from the financial information presented: Assets Liabilities Equity Your Basket $ ? $ 28,000 46,000 Flowers and Gifts 85,000 ?...
-
Bunker makes two types of briefcases, fabric and leather. The company is currently using a traditional costing system with labor hours as the cost driver but is considering switching to an...
-
Calculate the requested measures in parts (A) through (F) for bond X, assuming that it pays interest semiannually: (A) (B) (C) (D) (E) (F) Bond X Coupon 9% Yield to maturity 8% Maturity (years) 5 Par...
-
For this problem, assume that the variables f, g, h, and i are assigned to registers x5, x6, x7, x28 respectively. Assume base address in memory of Array data structures 'A, B, C' (or address in...
-
In Exercises find dy/dx by implicit differentiation. xy - y = x
-
Write a family database program. Create a class to represent a person and to store references to the persons mother, father, and any children the person has. Read a file of names to initialize the...
-
Write a method called collapse that accepts a stack of integers as a parameter and that collapses it by replacing each successive pair of integers with the sum of the pair. For example, if the stack...
-
If separate chaining is used for collision resolution, and the same elements from the previous problem (35, 2, 15, 80, 42, 95, and 66) are added to a hash table of size 10, what is the final state of...
-
What are the properties of instantaneous centre?
-
A chain with three links is shown in Fig.1.7. Prove that the chain is locked. 2 3 1 Fig.1.7 Three-bar chain
-
Differentiate between a mechanism and a machine.
Study smarter with the SolutionInn App