Lesson 3 125 Self-Check 11 1. How are type wrappers used in Java? XXXXXXXXXX__________________________________________________________ 2. What is boxing?...

1 answer below »
please see attached for my next java assignment that needs to get done.


Lesson 3 125 Self-Check 11 1. How are type wrappers used in Java? __________________________________________________________ 2. What is boxing? __________________________________________________________ 3. What is autoboxing? __________________________________________________________ 4. What primitive type is associated with the Integer wrapper class? __________________________________________________________ 5. Given the following method declaration, which type of objects are allowed for the array and elem parameters? > void sortArray (T[] array, T elem) __________________________________________________________ __________________________________________________________ Check your answers with those on page 205. Programming in Java126 NOTES Lesson 3 127 Object-Oriented Programming OVERVIEW After reading selected sections of Chapters 4, 6, 7, 8, 12, and 13 in the textbook and completing Lesson 3, you’re ready to begin coding with object-oriented programming (OOP) on your own. This project will assess your understanding of creating a class hierarchy in a package and writing code for classes and enumerations. Make sure that you follow all directions completely and verify your results before submitting the project. Remember to include all required components in your solution. YOUR PROJECT In this project, you’ll create data types in a class structure for cell-based board games similar to Tic-Tac-Toe. Games like Connect Four and Mastermind also use boards divided by rows and columns. The Board and Cell classes represent the board, while the Player, Mark, and Outcome enumerations track the game. You’ll use the classes and enumerations created in this project in future graded projects. You use the NetBeans project in the next lesson. G ra d e d P ro je c t G ra d e d P ro je c t Programming in Java128 INSTRUCTIONS 1. In NetBeans, create a new Java Application project named BoardGameTester. 2. Create a new package named games and a sub-package of games named board. The easiest way is simply to create a package named games.board. 3. Add an enumeration named Player to the games.board package. You could add Empty Java File or choose Java Enum as the file type. This enumeration represents the current player in a turn-based game. Use the follow- ing code: public enum Player {FIRST,SECOND} Note: Although Tic-Tac-Toe and Mastermind allow only two players, Connect Four can be played with up to four players. For simplicity, our code will handle only two players. 4. Add an enumeration named Outcome to the games.board package. This enumeration represents the result when the turn is completed. Use the following code: 5. Add an enumeration named Mark to the games.board package. This enumeration represents the result when the game is completed. Use the following code: Keep in mind that only yellow and red are used in Connect Four, while Mastermind uses all six colors. public enum Outcome {PLAYER1_WIN, PLAYER2_WIN, CONTINUE, TIE} public enum Mark {EMPTY, NOUGHT, CROSS, YELLOW, RED, BLUE, GREEN, MAGENTA, ORANGE} Lesson 3 129 - 6. Add the Cell class to the games.board package. It should have the private variables content, row, and column, and the public methods getContent, setContent, getRow, and getColumn. Use the following code as a guide: public class Cell { private Mark content; private int row, column; public Cell(int row, int column) { this.row = row; this.column = column; content = Mark.EMPTY; } public Mark getContent() { return content; } Take note that all classes that support direct instantiation should have a constructor. In this case, the constructor will be used by the Board class to create each of its cells. public void setContent(Mark content) { this.content = content; } public int getRow() { return row; } public int getColumn() { return column; } } Programming in Java130 7. Add the Board class to the games.board package. It should have a two-dimensional array of Cell objects. The Board class should initialize a board with a specified number of columns and rows, provide access to Cell objects, and display all of its cells correctly. Use the following code as a guide: public class Board { private Cell[][] cells; public Board(int rows, int columns) { cells = new Cell[rows][columns]; for( int r = 0; r < cells[0].length;="" r++="" )="" {="" for="" (int="" c="0;" c="">< cells[1].length;="" c++)="" {="" cells[r][c]="new" cell(r,c);="" }="" }="" }="" public="" void="" setcell(mark="" mark,="" int="" row,="" int="" column)="" throws="" illegalargumentexception="" {="" if="" (cells[row][column].getcontent()="=" mark.empty)="" cells[row][column].setcontent(mark);="" else="" throw="" new="" illegalargumentexception(“player="" already="" there!”="" );="" }="" public="" cell="" getcell(int="" row,="" int="" column)="" {="" return="" cells[row][column];="" }="" public="" string="" tostring()="" {="" stringbuilder="" str="new" stringbuilder();="" for(="" int="" r="0;" r="">< cells.length;="" r++="" )="" {="" str.append(“|”="" );="" for="" (int="" c="0;" c="">< cells[r].length;="" c++)="" {="" switch(cells[r][c].getcontent())="" {="" lesson="" 3="" 131="" case="" nought:="" str.append(“o”="" );="" break;="" case="" cross:="" str.append(“x”="" );="" break;="" case="" yellow:="" str.append(“y”="" );="" break;="" case="" red:="" str.append(“r”="" );="" break;="" case="" blue:="" str.append(“b”="" );="" break;="" case="" green:="" str.append(“g”="" );="" break;="" case="" magenta:="" str.append(“m”="" );="" break;="" case="" orange:="" str.append(“m”="" );="" break;="" default:="" empty="" str.append(“="" “);="" }="" str.append(“|”="" );="" }="" str.append(“\n”="" );="" }="" return="" str.tostring();="" }="" }="" programming="" in="" java132="" this="" code="" should="" seem="" familiar="" to="" you.="" the="" methods="" in="" the="" tictactoegame="" class="" are="" similar="" to="" those="" in="" the="" board="" class.="" the="" stringbuilder="" class="" was="" used="" instead="" of="" the="" string="" class="" for="" better="" performance.="" you="" can="" learn="" more="" about="" the="" stringbuilder="" class="" by="" visiting="" the="" oracle="" website="" at="" http://docs.oracle.com/javase/="" tutorial/java/data/buffers.html.="" 8.="" add="" the="" following="" import="" statement="" to="" the="" boardgametester="" class:="" import="" games.boards.*;="" 9.="" in="" the="" main()="" method="" of="" boardgametester,="" perform="" the="" following="" actions:="" a.="" create="" a="" 3="" �="" 3="" board="" for="" a="" tic-tac-toe="" game.="" b.="" create="" a="" 6="" �="" 7="" board="" for="" a="" connect="" four="" game.="" c.="" create="" a="" 5="" �="" 8="" board="" for="" a="" game="" of="" mastermind.="" d.="" set="" a="" cell="" to="" a="" nought="" or="" cross="" on="" the="" tic-tac-toe="" board.="" e.="" set="" a="" cell="" to="" yellow="" or="" red="" on="" the="" connect="" four="" board.="" f.="" set="" a="" cell="" to="" yellow,="" red,="" green,="" blue,="" magenta,="" or="" orange="" on="" the="" mastermind="" board.="" g.="" display="" the="" boards="" for="" tic-tac-toe,="" connect="" four,="" and="" mastermind.="" 10.="" compile="" and="" run="" the="" project="" to="" ensure="" it="" works="" as="" you="" expected="" it="" to.="" lesson="" 3="" 133="" submission="" guidelines="" to="" submit="" your="" project,="" you="" must="" provide="" the="" following="" source="" code="" files="" in="" a="" zip="" file:="" �="" boardgametester.java="" �="" board.java="" �="" cell.java="" �="" mark.java="" �="" outcome.java="" �="" player.java="" to="" find="" these="" files="" in="" netbeans,="" go="" to="" the="" boardgametester="" project="" folder.="" to="" determine="" this="" folder,="" right-click="" on="" the="" boardgametester="" project="" in="" the="" projects="" panel.="" copy="" the="" value="" for="" the="" project="" folder="" textbox="" using="" the="" keyboard="" shortcut="" ctrl+c.="" in="" windows="" explorer,="" paste="" the="" project="" folder="" path="" and="" hit="" the="" enter="" key.="" right-click="" on="" the="" src="" folder="" and="" choose="" the="" send="" to...=""> Compressed (zipped) folder option from the context menu. Rename the file to BoardGameTester_Lesson3.zip and copy it to your desktop or any other temporary location. Follow this procedure to submit your project online: 1. Log on to the Penn Foster website and go to student por- tal. 2. Click Take Exam. 3. Attach your Zip file as follows: a. Click on the Browse box. b. Locate the file you wish to attach. c. Double-click on the file. d. Click Upload File. Programming in Java134 4. Enter your e-mail address in the box provided. (Note: This information is required for online submissions.) 5. If you wish to tell your instructor anything specific regarding this assignment, enter it in the Message box. 6. Click Submit File. Grading Criteria Your instructor will use the following guidelines to grade your project. All types are organized in correct package hierarchy 10 points Mark enumeration correctly defined 5 points Outcome enumeration correctly defined 5 points Player enumeration correctly defined 5 points Cell class correctly defined 10 points Board class correctly defined 10 points BoardGameTester class correctly defined 20 points The application returns expected output 25 points All source code files are included: 10 points TOTAL 100 points 135 Advanced Programming Logic INTRODUCTION So far the applications you’ve designed are transient and unoptimized. They’re effective as long as a user keeps the program running and performs one simple action at a time. Well-built applications usually take advantage of a user’s local storage and memory/CPU utilization. Increasingly, applications are expected to implement complex tasks as simply as possible. In this lesson, you’ll learn how to load and save data to files, and to use multithreading techniques and lambda expressions to improve the consistency and per- formance of your applications. OBJECTIVES When you complete this lesson, you’ll be able to � Differentiate between the I/O classes provided by Java � Write data from an application to a file, then read data from a file back into an application � Access a local user’s system using the java.nio package � Define lambda expressions and blocks � Define functional interfaces � Reference methods � Use the java.util.function package � Create a custom thread using the Thread class and Runnable interface � Control a running thread’s lifetime and priority � Use thread synchronization and notification techniques � Use the java.util.concurrency package L e s s o n 4 L e s s o n 4 Programming in Java136 ASSIGNMENT 12: USE I/O CLASSES Read Assignment 12 in this study guide. Then read Chapter 10 in your textbook. Assignment 12 introduces basic input/output programming in Java and addresses I/O classes in the java.nio package. Be sure to complete the Try This activities in Chapter 10. Standard Stream Classes A stream is a sequential flow of data from a source to a destination. Sources can include files, network hosts, or even local String objects. Data sent through a stream can be raw bytes, individual characters, sequences of characters, or entire objects. Input streams read data from a stream, while output streams write data to a stream. There are many stream classes located in the java.io pack- age, each specialized for
Answered Same DayMar 10, 2021

Answer To: Lesson 3 125 Self-Check 11 1. How are type wrappers used in Java?...

Samrakshini R answered on Mar 11 2021
155 Votes
BoardGameTester/.classpath
    
    
    
BoardGameTester/.project
     BoardGameTester
    
    
    
    
        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
Bo
ardGameTester/.settings/org.eclipse.jdt.core.prefseclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
BoardGameTester/bin/BoardGameTester.classpublic synchronized class BoardGameTester {
public void BoardGameTester();
public static void main(String[]);
}
BoardGameTester/bin/games/board/Board.classpackage games.board;
public synchronized class Board {
private Cell[][] cells;
public void Board(int, int);
public void setCell(Mark, int, int) throws IllegalArgumentException;
public Cell getCell(int, int);
public String toString();
}
BoardGameTester/bin/games/board/Cell.classpackage games.board;
public synchronized class Cell {
private Mark content;
private int row;
private int column;
public void Cell(int, int);
public Mark getContent();
public void setContent(Mark);
public int getRow();
public int getColumn();
}
BoardGameTester/bin/games/board/Mark.classpackage games.board;
public final synchronized enum Mark {
public static final Mark EMPTY;
public static final Mark NOUGHT;
public static final Mark CROSS;
public static final Mark YELLOW;
public static final Mark RED;
public static final Mark BLUE;
public static final Mark GREEN;
public static final Mark MAGENTA;
public static final...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here