Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Coord The coord class represents one row/column location on a board. It is intended to be used like an immutable pair of int values,

class Coord The coord class represents one row/column location on a board. It is intended to be used like an immutable pair of int values, so its only fields are final. This means we don't modify coordinates, we instead keep generating new coord objects based on old ones (translation: many of our methods will create and return another coord) public final int r, c methods public coord(int r, int c). Basic constructor. public coord up). Creates and returns a new coord that is one spot above the current spot (note: the row number gets smaller due to our chosen use of indexing!) public coord down(). Creates and returns a new coord that is one spot below the current spot. public coord left). Creates and returns a new coord that is one spot left of the current spot. public coord right ). Creates and returns a new coord that is one spot right the current spot. eoverride public String toString(). Creates and returns a string representation of the coord, which contains no spaces and follows the following pattern: (r,c). Examples: (0,o), (3,2). @override public boolean equals (Object other). An equality-check method which reports whether this object and other are both coord objects with the same r and c values or not. As this method tends to have some inheritance code involved, it is recommended to start with this template: @override public boolean equals (Object other) /7 first, check that the other is actually a Coord. if ( (other instanceof Coord)){ return false; // create a variable that remembers that other is a Coord, and not just the general object class Coord o = (Coord) other ; // TODO:check that they have the same r and c values. Manual Inspection Criteria (5%): follow the template for equals in each class that requires an equals method. Specifically, no shortcuts like comparing tostring() outputs are used

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_2

Step: 3

blur-text-image_3

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What are the three categories of time? (p. 291)

Answered: 1 week ago