Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 1.7, Problem 1.27CP
Explanation of Solution
Encapsulation:
Encapsulation is a
- The code and data can be specified as private or public inside an object...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Transcribed Image Text
JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2
Language is c++
Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the Windows operating system would contain a game called M inesweeper. The player would be presented with a grid, where they would have to click an empty part of the map. If they clicked on a hidden mine, the game would be instantly over. However, if they clicked a safe spot, a hint about nearby mines would be displayed and the player would click another spot. The goal would be to flag all the hidden mines without hitting one. (As an aside, many people did not know these rules and just clicked around randomly until they hit a mine)We will be developing a simplified version of this game. You will prompt the user for a grid size and then created a 2D array with equal width and height (C++ students: Check the Appendix for more information on how to do this). You will initialize the 2D char array with each element equallying a ‘?’ symbol. You will then randomly generate one “mine” value per…
Please solve this java problem and including the GUI to run it.
Chapter 1 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 1.3 - Why is the computer used by so many different...Ch. 1.3 - List the five major hardware components of a...Ch. 1.3 - Internally, the CPU consists of what two units?Ch. 1.3 - Prob. 1.4CPCh. 1.3 - Prob. 1.5CPCh. 1.3 - Prob. 1.6CPCh. 1.3 - What does the term multitasking mean?Ch. 1.5 - Describe the difference between a key word and a...Ch. 1.5 - Prob. 1.9CPCh. 1.5 - Describe the difference between a program line and...
Ch. 1.5 - Prob. 1.11CPCh. 1.5 - What happens to a variables current contents when...Ch. 1.5 - What is a compiler?Ch. 1.5 - Prob. 1.14CPCh. 1.5 - What is byte code?Ch. 1.5 - Prob. 1.16CPCh. 1.6 - What four items should you identify when defining...Ch. 1.6 - Prob. 1.18CPCh. 1.6 - What is pseudocode?Ch. 1.6 - Describe what a compiler does with a programs...Ch. 1.6 - Prob. 1.21CPCh. 1.6 - Is a syntax error (such as misspelling a key word)...Ch. 1.6 - What is the purpose of testing a program with...Ch. 1.7 - Prob. 1.24CPCh. 1.7 - Prob. 1.25CPCh. 1.7 - Prob. 1.26CPCh. 1.7 - Prob. 1.27CPCh. 1.7 - Prob. 1.28CPCh. 1 - Prob. 1MCCh. 1 - A byte is made up of eight a. CPUs b. addresses c....Ch. 1 - Each byte is assigned a unique a. address b. CPU...Ch. 1 - Prob. 4MCCh. 1 - If you were to look at a machine language program,...Ch. 1 - These are words that have a special meaning in the...Ch. 1 - These are symbols or words that perform operations...Ch. 1 - These characters serve specific purposes, such as...Ch. 1 - These are words or names that are used to identify...Ch. 1 - Prob. 10MCCh. 1 - Prob. 11MCCh. 1 - Prob. 12MCCh. 1 - Prob. 13MCCh. 1 - The following pseudocode algorithm has an error....Ch. 1 - Available Credit A program that calculates a...Ch. 1 - Sales Tax A program that calculates the total of a...Ch. 1 - Account Balance A program that calculates the...Ch. 1 - The variable x starts with the value 0. The...Ch. 1 - The variable a starts with the value 10. The...Ch. 1 - Prob. 1SACh. 1 - Prob. 2SACh. 1 - What is the difference between operating system...Ch. 1 - Why must programs written in a high-level language...Ch. 1 - Why is it easier to write a program in a...Ch. 1 - What is a source file?Ch. 1 - Prob. 7SACh. 1 - What is an algorithm?Ch. 1 - What is a compiler?Ch. 1 - What must a computer have in order for it to...Ch. 1 - What is the difference between machine language...Ch. 1 - Why does byte code make Java a portable language?Ch. 1 - Prob. 13SACh. 1 - Prob. 14SACh. 1 - What part of an object forms an interface through...Ch. 1 - What type of program do you use to write Java...Ch. 1 - Will the Java compiler translate a source file...Ch. 1 - What does the Java compiler translate Java source...Ch. 1 - Prob. 19SACh. 1 - Prob. 20SACh. 1 - Your First Java Program This assignment will help...
Knowledge Booster
Similar questions
- JAVA CODE PLS Rectangle by CodeChum Admin A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0,0), the bottom right corner of the console is point (MAX, MAX) and given two points (all "x" and "y" coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class for a point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the sample area() - computes and returns the area of a given rectangle perimeter() - computes and returns the perimeter of a given rectangle centerPoint() -…arrow_forwardA class object can encapsulate more than one [answer].arrow_forwardWhy is encapsulation called Data Hiding?arrow_forward
- 9 public class PictureViewer 10{ public static void main(String[] args) 11 12 // Step 2: Fix the syntax errors and submit it to Codecheck to pass the test. // Note: Do not add or remove any statements 13 // 14 15 // Do not change the semantics of each statement Do not add or remove any variables Do not add or remove any objects Magic numbers are allowed 16 17 18 // 19 // 20 // Create an object of Picture by loading an image Picture pic = Picture("starry_night.png"); 21 22 23 // Display the width and height System.out.println("Width : " + pic.getWidth()); System.out.println("Height: 24 25 + pic.getHeight()); %3D 26 27 // Increase the width by 50 on both sides and // increase the height by 40 on both sides. // Must use dw and dh when calling method grow(). int dw, dh = 40; pic.grow(dw, dh); 28 29 30 31 32 33 // Display the width and height System.out.println("Width : System.out.println("Height: 34 + pic.getWidth()); + pic.getHeight()); 35 36 37 // Draw the picture draw(); 38 39 40 //…arrow_forwardOBJECT ORIENTED IN JAVA Example for VERSION 1: Welcome to Nick's Neon Tubing Calculator Enter the shape type (R, S, C, T, L, Q): R Enter Height and Width of Rectangle: 6.5 12 The perimeter of a 6.5 x 12 rectangle is 37.0 Enter the shape type (R, S, C, T, L, Q): C Enter Diameter: 12 The circumference of circle with diameter 12 is 37.7 Enter the shape type (R, S, C, T, L, Q): Q Shapes Needed 37.0 - rectangle, 6.5 x 12 37.7 - circle, diameter 12 --------------------------- 74.7 Total Length Thank You there is a version 2 as well, if you look at the pictures. Every person I have asked to help has either not made it object oriented or that code did not work. PLEASE help.arrow_forwardC# Code: There are two A, B players playing the game. Player A is angry with him, and player B is angry with him. Both s and t include only small English letters and are of equal length. A makes the first move, then B, then A, and so on. Before the start of the game, players are familiar with the content of both the letter s and t characters. These players form one rope during the game. Initially, the character unit w is empty. In each move, the player removes any single letter from the alphabetical order in order and adds this letter any (any position) to the letter w you can add a character to any index. Please refer to the Definitions for more specifications). If in any stage of the game, the character unit w is more than 1 length and is a palindrome, the player who made the last move wins. If even after the end of the game (i.e., when both s and t are empty strings), no one can make a unit of characters w a palindrome, and then player B wins. Given the unit of the letters s, and t,…arrow_forward
- public class StairViewer public static void main(String(] args) // Step 2: Create a rectangle and draw it as the // top step of the stair // location: (20, 10) // size: (20, 20) 18 // Step 3: Create a rectangle and draw it as the 19 // middle step of the stair 20 // location: below the top step, aligned on left // size: (40, 20) 21 22 23 24 // Step 4: Create a rectangle and draw it as the 25 // bottom step of the stair 26 // location: below the middle step, aligned on left // size: (60, 20) 27 28 29 30 } 31 32arrow_forwardDefine the class given from the picture using javaarrow_forwardComputer Science I need the code for this in Alice programming Faery Magic Create a world that has at least 5 different objects from the Furniture Gallery and one Faery from the Fantasy/Faeries Gallery. The Faery has the power to make an object disappear. Everything that the faery touches disappear from the scene. Create an interactive game where the user can click one object at a time from the scene; then, the faery faces that object and moves toward it. Write a recursive method named CheckDistance, that checks whether the faery is very close to the object clicked by the user. If it is, the faery bends over to touch the object. After the faery touches the object, the object disappears (this is the base case of the recursion). If the faery is not yet close enough to the object to be able to touch it, the faery moves a small distance forward and the CheckDistance method is recursively called (this is the recursive case of the recursion). Include instructions for the game that appears…arrow_forward
- Q code for design in java a circle image of food is placed in an ellipse shape of cream color when a button is placed 9 times then the ellipse starts rotating and so does the circle shape in it.arrow_forwardAbstract Algera: Exhibit all 7 composition series for D8.arrow_forwardJava Constructor(String) This constructor will take a string of digits(no commas) and turn it into an UnboundedInt object (MUST BE STRING INPUT) UnboundedInt add (UnboundedInt ) A method that adds the current UnboundedInt with a passed in one. The return is a new UnboundedInt. UnboundedInt multiply (UnboundedInt ) - do this one last! A method that multiplies the current UnboundedInt with a passed in one. The return is a new UnboundedInt. void addEnd ( int ) -optional method (helpful) A method to add a new element at the end of the sequence , used for building up each higher term in a single sequence. (i.e. adding a new IntNode to the linked list) UnboundedInt clone( ) a method that returns a copy of the original structure boolean equals ( Object ) a method that returns true if linked list represents the same numerical number as the input parameter. False otherwise. Overrides method in Object class. String toString ( ) creates a string of all elements…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT