You must write a code to represent the game of Dots and Boxes, allowing two people to play. The code should be exceptionally well organized and very easy to follow. Variables, methods, and classes...

1 answer below »
You must write a code to represent the game of Dots and Boxes, allowing two people to play. The code should be exceptionally well organized and very easy to follow. Variables, methods, and classes should be named well. Arrays, loops, methods, & objects should be used anywhere they could reasonably be used. Each section of the program should be fully commented. Code should be written in Java format and simple language. I will attach a pdf textbook, material from chapters 1-7 should be used. Main focus should be on chapters 3-7.


Starting Out with Java From Control Structures through Objects Sixth Edition Java Starting Out with Java From Control Structures through Objects TM This page intentionally left blank Java S i x t h E d i t i O n Tony Gaddis Haywood Community College Starting Out with Java From Control Structures through Objects Boston Columbus Indianapolis New York San Francisco Hoboken Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montréal Toronto Delhi Mexico City São Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo TM Editor in Chief: Marcia Horton Acquisitions Editor: Matt Goldstein Editorial Assistant: Kelsey Loanes VP of Marketing: Christy Lesko Director of Field Marketing: Tim Galligan Product Marketing Manager: Bram van Kempen Field Marketing Manager: Demetrius Hall Marketing Assistant: Jon Bryant Director of Product Management: Erin Gregg Team Lead Product Management: Scott Disanno Program Manager: Carole Snyder Production Project Manager: Camille Trentacoste Procurement Manager: Mary Fischer Senior Specialist, Program Planning and Support: Maura Zaldivar-Garcia Cover Designer: Joyce Wells Cover Image: Binh Thanh Bui/Shutterstock Manager, Rights Management: Rachel Youdelman Associate Project Manager, Rights Management: William J. Opaluch Full-Service Project Management: Kailash Jadli, Aptara®, Inc. Composition: Aptara®, Inc. Printer/Bindery: Edwards Brothers Cover printer: Phoenix Color/Hagerstown Copyright © 2016 by Pearson Education, Inc. or its affiliates. All Rights Reserved. Printed in the United States of America. This publication is protected by copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions department, please visit www.pearsoned.com/permissions/. Many of the designations by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps. Unless otherwise indicated herein, any third-party trademarks that may appear in this work are the property of their respective owners and any references to third-party trademarks, logos or other trade dress are for demonstrative or descriptive purposes only. Such references are not intended to imply any sponsorship, endorsement, authorization, or promotion of Pearson’s products by the owners of such marks, or any relationship between the owner and Pearson Education, Inc. or its affiliates, authors, licensees or distributors. Microsoft and/or its respective suppliers make no representations about the suitability of the information contained in the documents and related graphics published as part of the services for any purpose. All such documents and related graphics are provided “as is” without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information, including all warranties and conditions of merchantability. Whether express, implied or statutory, fitness for a particular purpose, title and non-infringement. In no event shall microsoft and/or its respective suppliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract. Negligence or other tortious action, arising out of or in connection with the use or performance of information available from the services. The documents and related graphics contained herein could include technical inaccuracies or typographical errors changes are periodically added to the information herein. Microsoft and/or its respective suppliers may make improvements and/or changes in the product(s) and/or the program(s) described herein at any time partial screen shots may be viewed in full within the software version specified. Microsoft® Windows®, and Microsoft Office® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. Library of Congress Cataloging-in-Publication Data Gaddis, Tony, author. Starting out with Java. From control structures through objects/Tony Gaddis, Haywood Community College.—6th edition. pages cm ISBN-13: 978-0-13-395705-1 ISBN-10: 0-13-395705-5 1. Java (Computer program language) 2. Data structures (Computer science) 3. Object-oriented programming (Computer science) I. Title. QA76.73.J38G333 2016 005.13'3—dc23 2014049102 10 9 8 7 6 5 4 3 2 1 ISBN-13: 978-0-13-395705-1 ISBN-10: 0-13-395705-5 http://www.pearsoned.com/permissions v Contents in Brief Preface xxiii Chapter 1 Introduction to Computers and Java 1 Chapter 2 Java Fundamentals 27 Chapter 3 Decision Structures 111 Chapter 4 Loops and Files 189 Chapter 5 Methods 269 Chapter 6 A First Look at Classes 319 Chapter 7 Arrays and the ArrayList Class 405 Chapter 8 A Second Look at Classes and Objects 495 Chapter 9 Text Processing and More about Wrapper Classes 559 Chapter 10 Inheritance 613 Chapter 11 Exceptions and Advanced File I/O 703 Chapter 12 A First Look at GUI Applications 761 Chapter 13 Advanced GUI Applications 849 Chapter 14 Applets and More 917 Chapter 15 Creating GUI Applications with JavaFX and Scene Builder 991 Chapter 16 Recursion 1047 Chapter 17 Databases 1075 Index 1171 Appendixes A–M Companion Website Case Studies 1–7 Companion Website This page intentionally left blank Preface xxiii Chapter 1 Introduction to Computers and Java 1 1.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Why Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Computer Systems: Hardware and Software. . . . . . . . . . . . . . . . . . . . . 2 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 1.4 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 What Is a Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 A History of Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Java Applications and Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 1.5 What Is a Program Made Of? . . . . . . . . . . . . .
Answered Same DayDec 08, 2021

Answer To: You must write a code to represent the game of Dots and Boxes, allowing two people to play. The code...

Ayush answered on Dec 11 2021
135 Votes
Dots and Boxes/Action.java
Dots and Boxes/Action.java
package com.example.dotsandboxes;

import com.example.dotsandboxes.Boxes;
import com.example.dotsandboxes.Player;

public class Action { 

    private Play
er m_PlayerAction = null;
    private boolean m_bChangePlayer = true;
    private Box[][] m_Boxes = null;
    private double m_dbValue = 0;

    public Action(){ 
        m_PlayerAction = null;
        m_Boxes = null;
        m_dbValue = 0;
    } 

    /**
     * copy

     *
     * @param testAction
     */
    public Action(Action testAction) { 
        m_Boxes = new Box[testAction.m_Boxes.length][testAction.m_Boxes[0].length];

        // iterates over the matrix, creating the box
        for(int i=0; i            for(int j=0; j                m_Boxes[i][j] = new Box(testAction.m_Boxes[i][j]);
 
                // links the box to its top box, and vice-versa
                if(i>0) 
                    m_Boxes[i][j].setTopBox(m_Boxes[i-1][j], true);
 
                // links the box to its left box, and vice-versa
                if(j>0) 
                    m_Boxes[i][j].setLeftBox(m_Boxes[i][j-1], true);
            } 
        } 
        m_PlayerAction = new Player(testAction.m_PlayerAction);
        m_dbValue = testAction.m_dbValue;
        m_bChangePlayer = testAction.m_bChangePlayer;
    } 

    public Box[][] getBoxes() { 
        return m_Boxes;
    } 
    public double getValue() { 
        return m_dbValue;
    } 
    public Player getPlayerAction() { 
        return m_PlayerAction;
    } 
    public void setBoxes(Box[][] boxes) { 
        m_Boxes = boxes;
    } 
    public void setValue(double value) { 
        m_dbValue = value;
    } 
    public void setPlayerAction(Player playerAction) { 
        m_PlayerAction = playerAction;
    } 
    public boolean isChangePlayer() { 
        return m_bChangePlayer;
    } 
    public void setChangePlayer(boolean changePlayer) { 
        m_bChangePlayer = changePlayer;
    } 

 
Dots and Boxes/Boxes.java
Dots and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here