This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TOPICS: 2 dimensional arrays, classes, constructors, mutators, accessors, iteration. Moderately Difficult | |
| This assignment is based on problem P7.10 in edition 8/e of your text. This problem is also in earlier editions. The problem involves the “Game of Life”. To facilitate viewing each generation of the game you will be given two methods, 1 that sets the canvas size based on the size of the “board” and one that draws the board to the screen using StdDraw. These method may need to be modified based on the implementation of YOUR class. | |
| To implement this project you will create a class Life. The class contains a 2-D array for the game board. The data type of the array can be either character or integer (Your choice). Each element in the array represents one square in the game board that represents a “cell” that is in one of 4 states: occupied, empty/free, being born (in the next generation), or dying (in the next generation). The board evolves through a series of generations with generation 0 (zero |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Trains as Objects | |
| We’re back on the container train! This time we’ll use an ArrayList as the storage instead of an array. We can do many of the same things with an ArrayList as with arrays, but we can do additional things, like add a new element onto the end. Like arrays, we can manipulate ArrayLists with loops. | |
| 1. Create classes named as specified in the UML. | |
| 2. The package name is specified in the assignment statement on Blackboard. | |
| 3. Notice that the members of the Train class are not static. (No underline.) | |
| 4. The Train class will have the following methods: | |
| a. A public constructor with no parameters. Initialize the private ArrayList. | |
| b. A public constructor with one parameter. Copy the parameter ArrayList to the private ArrayList. (Copy the whole thing, not just the reference. Hint: it’s much like copying an array: use a loop.) | |
| c. A public method setContainer. If the int parameter variable’s value is in the range 0 - (size of the ArrayList - 1), set (change) the appropriate String in the privat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scenario | |
| You are a Junior Developer employed by Turtle Shell Software Solutions who has recently been approached by a local printer firm to, to help them with booking and pricing. | |
| The local printer company have asked for a calculator to work out the costs per order and size of paper the client might need. They would like you to create a Java Application for booking staff to use. | |
| The table below details the different costs that need to be considered when creating the application. | |
| Initial one off Fee A1 A2 A3 A4 How many copies Req. | |
| Week days £0.40 £1.00 0.65 0.45 0.25 | |
| Weekends £1.00 £1.20 0.75 0.55 0.35 | |
| Urgent Prints £1.80 £2.00 0.95 0.65 0.45 | |
| Requirements of the application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Problem Description: | |
| The problem to be solved is the building of a quick- sort program using recursion. Advantages of this approach to the problem are: | |
| a. The sorting process is very time-efficient | |
| b. It can operate in-place, that is, in the original array. | |
| The use of recursion in this algorithm makes the logic quite simple. The array to be sorted is split in two sections, each section is sorted and the sorted sections are put together. The function that divides the array does so by picking one element in the array and using it as a so-called “pivot”. The array is separated into two portions such that every element in one portion is less than the pivot-element and every element in the other portion is greater than or equal to the pivot-element. The algorithm then calls itself on each portion; this process continues until the portion to be sorted contains 1 or 2 elements. After the second portion has been returned, sorted, the two portions are already in-place and the result is the entire array, sorted. | |
| The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For this project, you will revisit the Vampire Hunt game, rewriting it in an object-oriented style, as we discussed in lecture. A skeleton program (haha) is available on libra.sfsu.edu; you have to fill in code in various places in the file. If you follow the instructions in this handout, this will be a fairly straightforward project. Otherwise, you may spend lots of time working on unnecessary tasks. | |
| The action takes place on a 10 x 10 display grid, similar to the one you used for the Game of Life project. When the game begins, the user is prompted for the (i, j) coordinates of the vampire, and the (i, j) coordinates of the human. i and j are the row and column numbers of the position of an element in a 2-dimensional array; hence, the order is reversed from the usual (x, y) coordinates. | |
| Then the user is asked if s/he would like the human to move. (It’s easier to specify that the human does not move, for testing the program; normally we would have the human move, of course!) | |
| The user types in commands to m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FWPoint { | |
| private double xValue; | |
| private double yValue; | |
| public FWPoint(double xValue, double yValue) { // constructor | |
| this.xValue = xValue; | |
| this.yValue = yValue; | |
| } | |
| public double getX() { // getter x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #---------------------------------------------------------------------- | |
| Programming Assignment 01 | |
| #---------------------------------------------------------------------- | |
| Purpose: | |
| * Demonstrate working programming environment(s). | |
| * Demonstrate elementary understanding of Regular Expressions and | |
| how to use them in a program. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FWPoint { | |
| private double xValue; | |
| private double yValue; | |
| public FWPoint(double xValue, double yValue) { // constructor | |
| this.xValue = xValue; | |
| this.yValue = yValue; | |
| } | |
| public double getX() { // getter x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.Scanner; | |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| public class HTML { | |
| public static void main(String[] args){ | |
| try{ | |
| System.out.println("Enter the filename"); | |
| Scanner scanner = new Scanner(System.in); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.EventQueue; | |
| import javax.swing.JFrame; | |
| import javax.swing.JButton; | |
| import java.awt.event.ActionListener; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.BorderLayout; | |
| import javax.swing.JTextField; | |
| import java.awt.Window.Type; | |
| import javax.swing.JLabel; |
NewerOlder