Please help with this. program must be written in C# .. All of the game logic must be written in a
seperate class using using an array that is passed in through a prperty that represents the game
board. The class needs to have methods to determine of someone won, or if there was a tie,
make sure all business logic is in a seperate class anot behind the UI..
***** These are the complete in instructions for the game assignment design
Create a Tic-Tac-Toe game that can be played by two players. The form will consist of a Tic-
Tac-Toe board in which the users’ click on to choose their space. As the game is being played
the Game Status section will tell whose turn it is. When someone wins or there is a tie, a message
will be displayed in the Game status section telling the users the status. When someone wins the
game the winning move needs to be indicated. There also needs to be a section that keeps track
of the number of wins for each player, and the number of ties. When the game is finished the
user may click the “Start Game” button to start a new game.
This program will consist of the main form and at least one class that will define the rules of the
game. This class will have an array that is passed in through a property that represents the game
board. The class will then have methods within it that determines if someone won, if there is a
tie, or if neither has occurred yet. Make sure all business logic is in a separate class and not
behind the UI.
EXTRA CREDIT (10 Points)
Create a computer player that can be played against. The computer player will need to be smart
enough to make a winning move or to block a winning move.
Solution
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Tic_Tac_Toe
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
Logic logicObj = new Logic();
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
int turn=1;
int click1=0,click2=0,click3=0,click4=0,click5=0,click6=0,click7=0,click8=0,click9=0;
int player1=0,player2=0;
void Button1Click(object sender, EventArgs e)
{
if(click1==0)
{
if(turn%2!=0)
{
button1.Text=\"X\";
click1++;
}
else
{
button1.Text=\"O\";
click1++;
}
turn++;
}
else
{
button1.Text=button1.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a==1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if(a==2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button2Click(object sender, EventArgs e)
{
if(click2==0)
{
if(turn%2!=0)
{
button2.Text=\"X\";
click2++;
}
else
{
button2.Text=\"O\";
click2++;
}
turn++;
}
else
{
button2.Text=button2.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, b.
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfudit652068
Working with Layout Managers. Notes: 1. In part 2, note that the Game class inherits from
JPanel. Therefore, the panel you are asked to add to the center of the content pane is the \"game\"
object. 2. In part 4, at the end of the function, call validate(). This is not mentioned in the book,
but it is mentioned in the framework comments.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Game extends JPanel
{
private JButton [][] squares;
private TilePuzzle game;
public Game( int newSide )
{
game = new TilePuzzle( newSide );
setUpGameGUI( );
}
public void setUpGame( int newSide )
{
game.setUpGame( newSide );
setUpGameGUI( );
}
public void setUpGameGUI( )
{
removeAll( ); // remove all components
setLayout( new GridLayout( game.getSide( ),
game.getSide( ) ) );
squares = new JButton[game.getSide( )][game.getSide( )];
ButtonHandler bh = new ButtonHandler( );
// for each button: generate button label,
// instantiate button, add to container,
// and register listener
for ( int i = 0; i < game.getSide( ); i++ )
{
for ( int j = 0; j < game.getSide( ); j++ )
{
squares[i][j] = new JButton( game.getTiles( )[i][j] );
add( squares[i][j] );
squares[i][j].addActionListener( bh );
}
}
setSize( 300, 300 );
setVisible( true );
}
private void update( int row, int col )
{
for ( int i = 0; i < game.getSide( ); i++ )
{
for ( int j = 0; j < game.getSide( ); j++ )
{
squares[i][j].setText( game.getTiles( )[i][j] );
}
}
if ( game.won( ) )
{
JOptionPane.showMessageDialog( Game.this,
\"Congratulations! You won!\ Setting up new game\" );
// int sideOfPuzzle = 3 + (int) ( 4 * Math.random( ) );
// setUpGameGUI( );
}
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed( ActionEvent ae )
{
for( int i = 0; i < game.getSide( ); i++ )
{
for( int j = 0; j < game.getSide( ); j++ )
{
if ( ae.getSource( ) == squares[i][j] )
{
if ( game.tryToPlay( i, j ) )
update( i, j );
return;
} // end if
} // end inner for loop
} // outer for loop
} // end actionPerformed method
} // end ButtonHandler class
} // end Game class
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class NestedLayoutPractice extends JFrame
{
private Container contents;
private Game game;
private BorderLayout bl;
private JLabel bottom;
// ***** Task 1: declare a JPanel named top
// also declare three JButton instance variables
// that will be added to the JPanel top
// these buttons will determine the grid size of the game:
// 3-by-3, 4-by-4, or 5-by-5
// Part 1 student code starts here:
// Part 1 student code ends here.
public NestedLayoutPractice()
{
super(\"Practicing layout managers\");
contents = getContentPane();
// ***** Task 2:
// instantiate the BorderLayout manager bl
// Part 2 student code starts here:
// set the layout manager of the content pane contents to bl:
game = new Game(3); // instantiating the GamePanel object
// add panel (game) to the center of the content pane
// Part 2 student code ends here.
bottom = new JLabel(.
You will write a multi-interface version of the well-known concentra.pdfFashionColZone
You will write a multi-interface version of the well-known concentration game: 1. The game
displays a grid of upper-case letters, with each letter appearing twice. 2. A player has a few
seconds to memorize the letters before they disappear. 3. The player then has to remember where
each pair was located.
line, then MultiConcentration starts with the text interface.
First the new game display will show the user the pairs he/she must guess, in a format similar to
the following example for size = 6
D H B C M I
H G K K A R
C N R E O E
Q O A Q L F
L F J P B G
P D N M I J
Memorize the above grid!
Note that the new game display uses pairs of distinct single uppercase capital letters distributed
at random on a square grid, starting at A and continuing until the grid is full.
This new game display shows for 10 seconds, after which it scrolls out of view. (To scroll it just
write about 25 newlines.) Then the standard game display appears.
The standard game display will look like the following example for size = 6
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
21 32 33 34 35 36
Enter a pair of numbers, or \"R\" to reset, or \"Q\" to quit:
reset, or \"Q\" to quit:
If the player makes an invalid entry (e.g. numbers out of range, number already guessed, no
blank separator, etc.) then a \"please reenter\" message is printed and the same display is shown
again.
If the player makes a bad guess, then a \"Sorry...\" message is printed and the same display is
shown again.
If the player enters an \"R\" for reset, then we start over, that is, the computer calculates a new
set of pairs and shows the new game display again.
If the player enters a \"Q\" for quit, then the game prints a \"Game Over\" message and ends.
3.4 Graphic Game Interface
If the player used the \"-g\" flag on the startup command line then MultiConcentration starts up
with the graphic interface.
You may design the graphic interface as you choose, as long as you use Swing and preserve the
steps in the game as described in the previous section.
One possible graphic interface is shown in Figure 1. In this design the new game display and the
standard game display have been replaced by a grid of buttons. Instead of entering pairs of
numbers, the player clicks on two of the buttons. The \"reset\" and \"quit\" commands are given
using a menu. Letters that have been correctly guessed are shown with a pink background color.
Messages to the player are shown in a text area under the grid.
4 GENERAL REQUIREMENTS
4.1 Design Requirements
Design your program with GUI classes, a main class, and Application Logic / Data classes as
described in my overheads on Design for Testability.
Do not use a package statement; name the main class MultiConcentration. (Otherwise the
startup command given in 3.1 would not work.)
You should have at least 5 classes, and not one of them should have more than 40% of the code.
Solution
import java.io.OutputStream;
import java.io.PrintStream;
public cl.
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
In Java using Eclipse, I\'m suppose to write a class that encapsulates a tic tac toe board using two
dimensional arrays. It should only involve the human player vs. the computer, and should
randomly select who should use \'X\' or \'O\' and whether the human player or the computer
should go first. Verify that all moves by the human player are to a valid space on the tic-tac-toe
board, and an incorrect choice should not halt or terminate the game. Below is my Java program
that is currently a work in progress. Can you help me remodify it? Thanks.
import java.util.Scanner;
public class LeavinesTicTacToe
{
public static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
final int SIZE = 3;
char[][] board = new char[SIZE][SIZE]; // game board
resetBoard(board); // initialize the board (with \' \' for all cells)
// First, welcome message and display the board.
System.out.println(\"===== WELCOME TO THE TIC-TAC-TOE GAME!! =====\ \");
showBoard(board);
// Then ask the user which symbol (x or o) he/she wants to play.
System.out.print(\" Which symbol do you want to play, \\\"x\\\" or \\\"o\\\"? \");
char userSymbol = sc.next().toLowerCase().charAt(0);
char compSymbol = (userSymbol == \'x\') ? \'o\' : \'x\';
// Also ask whether or not the user wants to go first.
System.out.println();
System.out.print(\" Do you want to go first (y/n)? \");
char ans = sc.next().toLowerCase().charAt(0);
int turn; // 0 -- the user, 1 -- the computer
int remainCount = SIZE * SIZE; // empty cell count
// THE VERY FIRST MOVE.
if (ans == \'y\') {
turn = 0;
userPlay(board, userSymbol); // user puts his/her first tic
}
else {
turn = 1;
compPlay(board, compSymbol); // computer puts its first tic
}
// Show the board, and decrement the count of remaining cells.
showBoard(board);
remainCount--;
// Play the game until either one wins.
boolean done = false;
int winner = -1; // 0 -- the user, 1 -- the computer, -1 -- draw
while (!done && remainCount > 0) {
// If there is a winner at this time, set the winner and the done flag to true.
done = isGameWon(board, turn, userSymbol, compSymbol); // Did the turn won?
if (done)
winner = turn; // the one who made the last move won the game
else {
// No winner yet. Find the next turn and play.
turn = (turn + 1 ) % 2;
if (turn == 0)
userPlay(board, userSymbol);
else
compPlay(board, compSymbol);
// Show the board after one tic, and decrement the rem count.
showBoard(board);
remainCount--;
}
}
// Winner is found. Declare the winner.
if (winner == 0)
System.out.println(\"\ ** YOU WON. CONGRATULATIONS!! **\");
else if (winner == 1)
System.out.println(\"\ ** YOU LOST.. Maybe next time :) **\");
else
System.out.println(\"\ ** DRAW... **\");
}
public static void resetBoard(char[][] brd)
{
for (int i = 0; i < brd.length; i++)
for (int j = 0; j < brd[0].length; j++)
brd[i][j] = \' \';
}
public static void showBoard(char[][] brd)
{
int numRow = brd.length;
int numCol = brd[0].length;
System.out.println();
// First write the column he.
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
I don\'t know what is wrong with this roulette program I can\'t seem to get it to run.
Game Class:
public class Game {
public static void main(String[] args) {
Table table = new Table();
BinBuilder bb = new BinBuilder();
Outcome black = new Outcome(\"Black\", 35);
Bet bet = new Bet(10, black);
table.placeBet(bet);
Bin bin = bb.wheel.get(8);
System.out.println(bin.toString());
System.out.println(table.bets.toString());
System.out.println(black.toString());
ListIterator i = table.bets.listIterator();
Iterator b = bin.outcomes.iterator();
while(i.hasNext()) {
System.out.println(i.next().outcome.name.toString());
while(b.hasNext()){
System.out.println(b.next().name.toString());
if(i.next().outcome.equals(b.next())){
System.out.println(\"Win!\");
}
else{
System.out.println(\"Win :/\");
}
}
}
}
}
Player Class
public class Player {
public Table table;
public Outcome black;
public Bet bet;
public Player(Table table) {
table = new Table();
black = new Outcome(\"Black\", 1);
}
void placeBets() {
Bet bet = new Bet(100, black);
table.placeBet(bet);
}
void win(Bet bet) {
System.out.println(\"You\'ve won: \" + bet.winAmount());
}
void lose(Bet bet) {
System.out.println(\"You lost!\" + bet.loseAmount() + \":/\");
}
}
Outcome class
public class Outcome implements Comparable {
public String name;
public int odds;
public Outcome(String name, int odds){
this.name = name;
this.odds = odds;
}
public int winAmount(int amount){
return amount*this.odds;
}
public boolean equals(Outcome other){
return (this.name.equals(other.name));
}
public String toString() {
Object[] values= { name, new Integer(odds) };
String msgTempl= \"{0} ({1}:1)\";
return MessageFormat.format( msgTempl, values );
}
@Override
public int compareTo(E arg0) {
if(this.equals(arg0)){
return 0;
}
return 1;
}
}
Table Class
public class Table {
public int limit = 1000;
public LinkedList bets;
public Table() {
bets = new LinkedList();
}
public boolean isValid(Bet bet) {
int sum = 0;
for(Bet bett: bets) {
sum += bett.amountBet;
}
return (sum>limit);
}
public void placeBet(Bet bet) {
bets.add(bet);
}
ListIterator iterator() {
return bets.listIterator();
}
}
Wheel Class
public class Wheel extends TreeSet {
Vector bins;
NonRandom rng;
Set all_outcomes;
Wheel(NonRandom rng){
this.rng = rng;
rng = new NonRandom();
all_outcomes = new TreeSet();
bins = new Vector(38);
for (int i=0; i<38; i++){
bins.add(i, new Bin());
}
}
Bin next(){
int rand = rng.next(38);
return bins.elementAt(rand);
}
Bin get(int bin){
return bins.elementAt(bin);
}
public Outcome getOutcome( String name ){
TreeSet result= new TreeSet();
for( Iterator i = all_outcomes.iterator(); i.hasNext(); ) {
Outcome oc= i.next();
if( oc.name.contains(name) ) {result.add( oc );}
}
return result.first();
}
public void addOutcome(int bin, Outcome outcome) {
all_outcomes.add(outcome);
this.bins.elementAt(bin).add(outcome);
}
}
Bet Class
public class Bet {
public int amountBet;
public Outcome outcome;
public Bet(int amount, Outcome outcome) {
this.outcome = o.
Objectives Create a Java program using programming fundamentals (fi.docxamit657720
Objectives: Create a Java program using programming fundamentals (file I/O, loops, conditional statements, arrays, functions)
Problem: In an effort to win a coding competition, you decided to create an awesome Obstacle Warrior game. The game is played on a 2-dimensional board similar to a Chess board, but the dimensions may be different. The minimum size of the board is 2x2. The board will have a Start square and an Exit square that are not stored on the board. Start and Exit squares cannot be the same. Other board squares may contain obstacles in the form of an integer that will define how the warrior position and score will be affected. The obstacle squares can have values from 0 to -10 only. The Start square is always a clear square. All clear squares are marked with # on the board. The Exit square may contain an obstacle that is not a zero. The size of the board, number of obstacles, and Start and Exit squares are all unknow to your code prior to running. This information is stored in a file that your code will read at the beginning of the game. The board.dat file must be read into a 2-D array.
A warrior must start at the Start square and find their way to the Exit square. The warrior can move on the board in any direction including diagonally, one square at a time. A warrior has a running score (integer) maintained from the start of the game until the warrior exits the board. If the warrior lands on an obstacle square with a value of zero, the warrior is sent back to the starting position and the obstacle square will become a normal square (obstacle removed). If the obstacle square has a negative number, that number will reduce the warrior's score by the value of the obstacle, and the obstacle square will become a clear square (obstacle removed). Each VALID move that the warrior makes without landing on an obstacle will earn the warrior one point. The moves for the warrior are randomly generated by your code in the form of a direction (0-UP, 1-DOWN, 2-LEFT, 3-RIGHT, 4-UPRIGHT, 5-DOWNRIGHT, 6-UPLEFT, 7-DOWNLEFT). If the warrior is at the boundary of the board and your code generates an invalid move, that move will be ignored. Your code will keep generating moves until the warrior exits at the Exit square. Once the warrior exits, your program will store the updated board information to a new file ResultBoard.dat as single-space separated data. The program will also display the total number of valid moves, the total time elapsed in milliseconds since the first move until the warrior exited the board, the final score of the warrior and the formatted board information (right aligned columns with total of 5 spaces).
Output Format:
Each column in the final board display must be of total width of 5 spaces
Data in each column must be right aligned
Enter the board data file path: C:\board.dat //Repeat prompt until valid file OR show error and exit.
Type "Start" to start the game or "Exit" to exit the game: exit //Your program must exit
E.
#In this project you will write a program play TicTacToe #using tw.pdfaquacareser
#In this project you will write a program play TicTacToe
#using two players (labels 0,1) or one play (label 0) playing with the machine (label 1).
#The TicTacToe board has 9 integers board = [1,2,3,4,5,6,7,8,9]. The following
# are the modules for the program
#
#def reset() resets the board to the original values
# board = [1,2,3,4,5,6,7,8,9]
#
#def printBoard() print the current state of the board using the format
#
#The current TicTacToe Board
# | 1 | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#
#The current TicTacToe Board
# | X | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#Note from the above that player 0 and 1 have played numbers 8 and 1
#respectively and the board display O for player 0 and X from player 1
#
#def changeBoard(num1, player) using the chosen box number to change
#the value of the box to 0 or -1 depending on whether the player is 0 or 1,
#respectively.
#
#def play(player) prints the player number (0 or 1) and prompts the player
# to enter a box value that have not changed to \'O\' or \'X\'
#
#def checkRows(value) checks to see which of the rows of the board
# has the same value and returns True, otherwise, returns False
#
#def checkCols(value) checks to see which of the cols of the board
# has the same value and returns True, otherwise, returns False
#
#def checkDiagonal(value) checks to see which of the diagonals of the board
# has the same value and returns True, otherwise, returns False
#
#def win(player) checks if a player wins the game, returns True of the player wins
# and False otherwise
#
#def machinePlay(player) plays the role of the player using random number.
# this function generates numbers in the interval [1,9] and uses the first
# generated random number that has not been used to play the game. The
#
#def ticTacToe(numPlayers) accepts the number of players and simulates the
#ticTapToe, asking players to enter unused box numbers.
#
#def main() is the driver module that accepts the number of players from the user
# and calls the ticTacToe module
#Assignment: Complete the follwoing modules:
#checkCols
#checkRows
#checkDiagonal
#win
#Sample of the output is
#
#Project
#This game can be played by one or two players
#Enter the number of players, 1/2 for one/two players: 1
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | 9 |
#Player 0 Enter a box value: 9
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | O |
#Player 1 ***Computer*** playing
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 1
#
#The current TicTapToe Board
#| O | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 1 ***Computer*** playing
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 5
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | O | 6 |
#| 7 | X | O |
#Player 0 Wins
#Do you want to quit?
#Begin Program
#import random number generator
#from random library
#from random import randint, seed
#Global va.
#In this project you will write a program play TicTacToe #using tw.pdfaquapariwar
#In this project you will write a program play TicTacToe
#using two players (labels 0,1) or one play (label 0) playing with the machine (label 1).
#The TicTacToe board has 9 integers board = [1,2,3,4,5,6,7,8,9]. The following
# are the modules for the program
#
#def reset() resets the board to the original values
# board = [1,2,3,4,5,6,7,8,9]
#
#def printBoard() print the current state of the board using the format
#
#The current TicTacToe Board
# | 1 | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#
#The current TicTacToe Board
# | X | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#Note from the above that player 0 and 1 have played numbers 8 and 1
#respectively and the board display O for player 0 and X from player 1
#
#def changeBoard(num1, player) using the chosen box number to change
#the value of the box to 0 or -1 depending on whether the player is 0 or 1,
#respectively.
#
#def play(player) prints the player number (0 or 1) and prompts the player
# to enter a box value that have not changed to \'O\' or \'X\'
#
#def checkRows(value) checks to see which of the rows of the board
# has the same value and returns True, otherwise, returns False
#
#def checkCols(value) checks to see which of the cols of the board
# has the same value and returns True, otherwise, returns False
#
#def checkDiagonal(value) checks to see which of the diagonals of the board
# has the same value and returns True, otherwise, returns False
#
#def win(player) checks if a player wins the game, returns True of the player wins
# and False otherwise
#
#def machinePlay(player) plays the role of the player using random number.
# this function generates numbers in the interval [1,9] and uses the first
# generated random number that has not been used to play the game. The
#
#def ticTacToe(numPlayers) accepts the number of players and simulates the
#ticTapToe, asking players to enter unused box numbers.
#
#def main() is the driver module that accepts the number of players from the user
# and calls the ticTacToe module
#Assignment: Complete the follwoing modules:
#checkCols
#checkRows
#checkDiagonal
#win
#Sample of the output is
#
#Project
#This game can be played by one or two players
#Enter the number of players, 1/2 for one/two players: 1
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | 9 |
#Player 0 Enter a box value: 9
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | O |
#Player 1 ***Computer*** playing
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 1
#
#The current TicTapToe Board
#| O | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 1 ***Computer*** playing
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 5
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | O | 6 |
#| 7 | X | O |
#Player 0 Wins
#Do you want to quit?
#Begin Program
#import random number generator
#from random library
#from random import randint, seed
#Global va.
public interface Game Note interface in place of class { .pdfkavithaarp
public interface Game // Note *interface* in place of *class*
{
/// play the game and return the final score
/// where a higher score should be better,
/// and a negative score is allowed.
int play(); // Note semicolon in place of a body
// You can have multiple method headings declared
}
--------------------------------------------------------------------------------------------------------------
import java.util.*;
/// Starting point for Interface Lab.
public class PlayGames
{
private static Scanner in;
private static Random rand = new Random();
private static int gameCount = 0;
public static Game popRandom(Game[] g)
{
int n = gameCount;
int i = rand.nextInt(n);
Game ret = g[i];
g[i] = g[n-1];
gameCount--;
return ret;
}
public static void main(String[] args)
{
Game[] games = new Game[10]; // Note Game as a type
games[gameCount] = new AdditionGame(rand, 100);
gameCount++; // next index to put a Game at
// write at least 2 more different types of Game classes
// and add a new one of each type to games
// ...
in = new Scanner(System.in);
int totScore = 0;
do {
Game g = popRandom(games);
totScore += g.play(); // use numerical result from the game
} while (gameCount > 0 && agree(\"Want a game? \"));
System.out.println(\"Thanks for Playing!\");
System.out.println(\"Your total score is \" + totScore);
}
public static boolean agree(String prompt)
{
System.out.print(prompt);
String input = in.next();
if (input.equalsIgnoreCase(\"y\")) return true;
return false;
}
--------------------------------------------------------------------------------------------------------------------
--
import java.util.*;
public class AdditionGame implements Game // note implements!!
{
private Random rand;
private int n;
// Constructor for objects of class AdditionGame
public AdditionGame(Random r, int big)
{
rand = r;
n = big;
}
// play all games and keep score.
public int play() // exactly matches heading in Game interface
{
final int numGames = 3;
Scanner in = new Scanner(System.in);
int score = 0;
System.out.println(\"Welcome to the addition game! We\'ll now play \" + numGames
+ \" rounds.\");
for (int i = 0; i < numGames; i++) {
int x = rand.nextInt(n), y = rand.nextInt(n), ans = x+y;
System.out.print(String.format(\"Enter the sum: %d + %d = \", x, y));
int val = in.nextInt();
if (ans == val) {
System.out.println(\"Correct!\");
score++;
}
else
System.out.println(\"Wrong! Right answer is \" + ans);
}
System.out.println(\"Thanks for playing the addition game. Your score is \" + score +
\".\");
System.out.println();
return score;
}
}
--------------------------------------------------------------------------------------------------------------------
---
Create two classes that implement a Game interface:
------------------------------------
There is a Game interface defined, and also a PlayGames class that uses objects from classes that
implement that interface. The Game interface declares a single abstract method play that returns
an int, the score from playing the gam.
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfudit652068
Working with Layout Managers. Notes: 1. In part 2, note that the Game class inherits from
JPanel. Therefore, the panel you are asked to add to the center of the content pane is the \"game\"
object. 2. In part 4, at the end of the function, call validate(). This is not mentioned in the book,
but it is mentioned in the framework comments.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Game extends JPanel
{
private JButton [][] squares;
private TilePuzzle game;
public Game( int newSide )
{
game = new TilePuzzle( newSide );
setUpGameGUI( );
}
public void setUpGame( int newSide )
{
game.setUpGame( newSide );
setUpGameGUI( );
}
public void setUpGameGUI( )
{
removeAll( ); // remove all components
setLayout( new GridLayout( game.getSide( ),
game.getSide( ) ) );
squares = new JButton[game.getSide( )][game.getSide( )];
ButtonHandler bh = new ButtonHandler( );
// for each button: generate button label,
// instantiate button, add to container,
// and register listener
for ( int i = 0; i < game.getSide( ); i++ )
{
for ( int j = 0; j < game.getSide( ); j++ )
{
squares[i][j] = new JButton( game.getTiles( )[i][j] );
add( squares[i][j] );
squares[i][j].addActionListener( bh );
}
}
setSize( 300, 300 );
setVisible( true );
}
private void update( int row, int col )
{
for ( int i = 0; i < game.getSide( ); i++ )
{
for ( int j = 0; j < game.getSide( ); j++ )
{
squares[i][j].setText( game.getTiles( )[i][j] );
}
}
if ( game.won( ) )
{
JOptionPane.showMessageDialog( Game.this,
\"Congratulations! You won!\ Setting up new game\" );
// int sideOfPuzzle = 3 + (int) ( 4 * Math.random( ) );
// setUpGameGUI( );
}
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed( ActionEvent ae )
{
for( int i = 0; i < game.getSide( ); i++ )
{
for( int j = 0; j < game.getSide( ); j++ )
{
if ( ae.getSource( ) == squares[i][j] )
{
if ( game.tryToPlay( i, j ) )
update( i, j );
return;
} // end if
} // end inner for loop
} // outer for loop
} // end actionPerformed method
} // end ButtonHandler class
} // end Game class
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class NestedLayoutPractice extends JFrame
{
private Container contents;
private Game game;
private BorderLayout bl;
private JLabel bottom;
// ***** Task 1: declare a JPanel named top
// also declare three JButton instance variables
// that will be added to the JPanel top
// these buttons will determine the grid size of the game:
// 3-by-3, 4-by-4, or 5-by-5
// Part 1 student code starts here:
// Part 1 student code ends here.
public NestedLayoutPractice()
{
super(\"Practicing layout managers\");
contents = getContentPane();
// ***** Task 2:
// instantiate the BorderLayout manager bl
// Part 2 student code starts here:
// set the layout manager of the content pane contents to bl:
game = new Game(3); // instantiating the GamePanel object
// add panel (game) to the center of the content pane
// Part 2 student code ends here.
bottom = new JLabel(.
You will write a multi-interface version of the well-known concentra.pdfFashionColZone
You will write a multi-interface version of the well-known concentration game: 1. The game
displays a grid of upper-case letters, with each letter appearing twice. 2. A player has a few
seconds to memorize the letters before they disappear. 3. The player then has to remember where
each pair was located.
line, then MultiConcentration starts with the text interface.
First the new game display will show the user the pairs he/she must guess, in a format similar to
the following example for size = 6
D H B C M I
H G K K A R
C N R E O E
Q O A Q L F
L F J P B G
P D N M I J
Memorize the above grid!
Note that the new game display uses pairs of distinct single uppercase capital letters distributed
at random on a square grid, starting at A and continuing until the grid is full.
This new game display shows for 10 seconds, after which it scrolls out of view. (To scroll it just
write about 25 newlines.) Then the standard game display appears.
The standard game display will look like the following example for size = 6
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
21 32 33 34 35 36
Enter a pair of numbers, or \"R\" to reset, or \"Q\" to quit:
reset, or \"Q\" to quit:
If the player makes an invalid entry (e.g. numbers out of range, number already guessed, no
blank separator, etc.) then a \"please reenter\" message is printed and the same display is shown
again.
If the player makes a bad guess, then a \"Sorry...\" message is printed and the same display is
shown again.
If the player enters an \"R\" for reset, then we start over, that is, the computer calculates a new
set of pairs and shows the new game display again.
If the player enters a \"Q\" for quit, then the game prints a \"Game Over\" message and ends.
3.4 Graphic Game Interface
If the player used the \"-g\" flag on the startup command line then MultiConcentration starts up
with the graphic interface.
You may design the graphic interface as you choose, as long as you use Swing and preserve the
steps in the game as described in the previous section.
One possible graphic interface is shown in Figure 1. In this design the new game display and the
standard game display have been replaced by a grid of buttons. Instead of entering pairs of
numbers, the player clicks on two of the buttons. The \"reset\" and \"quit\" commands are given
using a menu. Letters that have been correctly guessed are shown with a pink background color.
Messages to the player are shown in a text area under the grid.
4 GENERAL REQUIREMENTS
4.1 Design Requirements
Design your program with GUI classes, a main class, and Application Logic / Data classes as
described in my overheads on Design for Testability.
Do not use a package statement; name the main class MultiConcentration. (Otherwise the
startup command given in 3.1 would not work.)
You should have at least 5 classes, and not one of them should have more than 40% of the code.
Solution
import java.io.OutputStream;
import java.io.PrintStream;
public cl.
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
In Java using Eclipse, I\'m suppose to write a class that encapsulates a tic tac toe board using two
dimensional arrays. It should only involve the human player vs. the computer, and should
randomly select who should use \'X\' or \'O\' and whether the human player or the computer
should go first. Verify that all moves by the human player are to a valid space on the tic-tac-toe
board, and an incorrect choice should not halt or terminate the game. Below is my Java program
that is currently a work in progress. Can you help me remodify it? Thanks.
import java.util.Scanner;
public class LeavinesTicTacToe
{
public static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
final int SIZE = 3;
char[][] board = new char[SIZE][SIZE]; // game board
resetBoard(board); // initialize the board (with \' \' for all cells)
// First, welcome message and display the board.
System.out.println(\"===== WELCOME TO THE TIC-TAC-TOE GAME!! =====\ \");
showBoard(board);
// Then ask the user which symbol (x or o) he/she wants to play.
System.out.print(\" Which symbol do you want to play, \\\"x\\\" or \\\"o\\\"? \");
char userSymbol = sc.next().toLowerCase().charAt(0);
char compSymbol = (userSymbol == \'x\') ? \'o\' : \'x\';
// Also ask whether or not the user wants to go first.
System.out.println();
System.out.print(\" Do you want to go first (y/n)? \");
char ans = sc.next().toLowerCase().charAt(0);
int turn; // 0 -- the user, 1 -- the computer
int remainCount = SIZE * SIZE; // empty cell count
// THE VERY FIRST MOVE.
if (ans == \'y\') {
turn = 0;
userPlay(board, userSymbol); // user puts his/her first tic
}
else {
turn = 1;
compPlay(board, compSymbol); // computer puts its first tic
}
// Show the board, and decrement the count of remaining cells.
showBoard(board);
remainCount--;
// Play the game until either one wins.
boolean done = false;
int winner = -1; // 0 -- the user, 1 -- the computer, -1 -- draw
while (!done && remainCount > 0) {
// If there is a winner at this time, set the winner and the done flag to true.
done = isGameWon(board, turn, userSymbol, compSymbol); // Did the turn won?
if (done)
winner = turn; // the one who made the last move won the game
else {
// No winner yet. Find the next turn and play.
turn = (turn + 1 ) % 2;
if (turn == 0)
userPlay(board, userSymbol);
else
compPlay(board, compSymbol);
// Show the board after one tic, and decrement the rem count.
showBoard(board);
remainCount--;
}
}
// Winner is found. Declare the winner.
if (winner == 0)
System.out.println(\"\ ** YOU WON. CONGRATULATIONS!! **\");
else if (winner == 1)
System.out.println(\"\ ** YOU LOST.. Maybe next time :) **\");
else
System.out.println(\"\ ** DRAW... **\");
}
public static void resetBoard(char[][] brd)
{
for (int i = 0; i < brd.length; i++)
for (int j = 0; j < brd[0].length; j++)
brd[i][j] = \' \';
}
public static void showBoard(char[][] brd)
{
int numRow = brd.length;
int numCol = brd[0].length;
System.out.println();
// First write the column he.
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
I don\'t know what is wrong with this roulette program I can\'t seem to get it to run.
Game Class:
public class Game {
public static void main(String[] args) {
Table table = new Table();
BinBuilder bb = new BinBuilder();
Outcome black = new Outcome(\"Black\", 35);
Bet bet = new Bet(10, black);
table.placeBet(bet);
Bin bin = bb.wheel.get(8);
System.out.println(bin.toString());
System.out.println(table.bets.toString());
System.out.println(black.toString());
ListIterator i = table.bets.listIterator();
Iterator b = bin.outcomes.iterator();
while(i.hasNext()) {
System.out.println(i.next().outcome.name.toString());
while(b.hasNext()){
System.out.println(b.next().name.toString());
if(i.next().outcome.equals(b.next())){
System.out.println(\"Win!\");
}
else{
System.out.println(\"Win :/\");
}
}
}
}
}
Player Class
public class Player {
public Table table;
public Outcome black;
public Bet bet;
public Player(Table table) {
table = new Table();
black = new Outcome(\"Black\", 1);
}
void placeBets() {
Bet bet = new Bet(100, black);
table.placeBet(bet);
}
void win(Bet bet) {
System.out.println(\"You\'ve won: \" + bet.winAmount());
}
void lose(Bet bet) {
System.out.println(\"You lost!\" + bet.loseAmount() + \":/\");
}
}
Outcome class
public class Outcome implements Comparable {
public String name;
public int odds;
public Outcome(String name, int odds){
this.name = name;
this.odds = odds;
}
public int winAmount(int amount){
return amount*this.odds;
}
public boolean equals(Outcome other){
return (this.name.equals(other.name));
}
public String toString() {
Object[] values= { name, new Integer(odds) };
String msgTempl= \"{0} ({1}:1)\";
return MessageFormat.format( msgTempl, values );
}
@Override
public int compareTo(E arg0) {
if(this.equals(arg0)){
return 0;
}
return 1;
}
}
Table Class
public class Table {
public int limit = 1000;
public LinkedList bets;
public Table() {
bets = new LinkedList();
}
public boolean isValid(Bet bet) {
int sum = 0;
for(Bet bett: bets) {
sum += bett.amountBet;
}
return (sum>limit);
}
public void placeBet(Bet bet) {
bets.add(bet);
}
ListIterator iterator() {
return bets.listIterator();
}
}
Wheel Class
public class Wheel extends TreeSet {
Vector bins;
NonRandom rng;
Set all_outcomes;
Wheel(NonRandom rng){
this.rng = rng;
rng = new NonRandom();
all_outcomes = new TreeSet();
bins = new Vector(38);
for (int i=0; i<38; i++){
bins.add(i, new Bin());
}
}
Bin next(){
int rand = rng.next(38);
return bins.elementAt(rand);
}
Bin get(int bin){
return bins.elementAt(bin);
}
public Outcome getOutcome( String name ){
TreeSet result= new TreeSet();
for( Iterator i = all_outcomes.iterator(); i.hasNext(); ) {
Outcome oc= i.next();
if( oc.name.contains(name) ) {result.add( oc );}
}
return result.first();
}
public void addOutcome(int bin, Outcome outcome) {
all_outcomes.add(outcome);
this.bins.elementAt(bin).add(outcome);
}
}
Bet Class
public class Bet {
public int amountBet;
public Outcome outcome;
public Bet(int amount, Outcome outcome) {
this.outcome = o.
Objectives Create a Java program using programming fundamentals (fi.docxamit657720
Objectives: Create a Java program using programming fundamentals (file I/O, loops, conditional statements, arrays, functions)
Problem: In an effort to win a coding competition, you decided to create an awesome Obstacle Warrior game. The game is played on a 2-dimensional board similar to a Chess board, but the dimensions may be different. The minimum size of the board is 2x2. The board will have a Start square and an Exit square that are not stored on the board. Start and Exit squares cannot be the same. Other board squares may contain obstacles in the form of an integer that will define how the warrior position and score will be affected. The obstacle squares can have values from 0 to -10 only. The Start square is always a clear square. All clear squares are marked with # on the board. The Exit square may contain an obstacle that is not a zero. The size of the board, number of obstacles, and Start and Exit squares are all unknow to your code prior to running. This information is stored in a file that your code will read at the beginning of the game. The board.dat file must be read into a 2-D array.
A warrior must start at the Start square and find their way to the Exit square. The warrior can move on the board in any direction including diagonally, one square at a time. A warrior has a running score (integer) maintained from the start of the game until the warrior exits the board. If the warrior lands on an obstacle square with a value of zero, the warrior is sent back to the starting position and the obstacle square will become a normal square (obstacle removed). If the obstacle square has a negative number, that number will reduce the warrior's score by the value of the obstacle, and the obstacle square will become a clear square (obstacle removed). Each VALID move that the warrior makes without landing on an obstacle will earn the warrior one point. The moves for the warrior are randomly generated by your code in the form of a direction (0-UP, 1-DOWN, 2-LEFT, 3-RIGHT, 4-UPRIGHT, 5-DOWNRIGHT, 6-UPLEFT, 7-DOWNLEFT). If the warrior is at the boundary of the board and your code generates an invalid move, that move will be ignored. Your code will keep generating moves until the warrior exits at the Exit square. Once the warrior exits, your program will store the updated board information to a new file ResultBoard.dat as single-space separated data. The program will also display the total number of valid moves, the total time elapsed in milliseconds since the first move until the warrior exited the board, the final score of the warrior and the formatted board information (right aligned columns with total of 5 spaces).
Output Format:
Each column in the final board display must be of total width of 5 spaces
Data in each column must be right aligned
Enter the board data file path: C:\board.dat //Repeat prompt until valid file OR show error and exit.
Type "Start" to start the game or "Exit" to exit the game: exit //Your program must exit
E.
#In this project you will write a program play TicTacToe #using tw.pdfaquacareser
#In this project you will write a program play TicTacToe
#using two players (labels 0,1) or one play (label 0) playing with the machine (label 1).
#The TicTacToe board has 9 integers board = [1,2,3,4,5,6,7,8,9]. The following
# are the modules for the program
#
#def reset() resets the board to the original values
# board = [1,2,3,4,5,6,7,8,9]
#
#def printBoard() print the current state of the board using the format
#
#The current TicTacToe Board
# | 1 | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#
#The current TicTacToe Board
# | X | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#Note from the above that player 0 and 1 have played numbers 8 and 1
#respectively and the board display O for player 0 and X from player 1
#
#def changeBoard(num1, player) using the chosen box number to change
#the value of the box to 0 or -1 depending on whether the player is 0 or 1,
#respectively.
#
#def play(player) prints the player number (0 or 1) and prompts the player
# to enter a box value that have not changed to \'O\' or \'X\'
#
#def checkRows(value) checks to see which of the rows of the board
# has the same value and returns True, otherwise, returns False
#
#def checkCols(value) checks to see which of the cols of the board
# has the same value and returns True, otherwise, returns False
#
#def checkDiagonal(value) checks to see which of the diagonals of the board
# has the same value and returns True, otherwise, returns False
#
#def win(player) checks if a player wins the game, returns True of the player wins
# and False otherwise
#
#def machinePlay(player) plays the role of the player using random number.
# this function generates numbers in the interval [1,9] and uses the first
# generated random number that has not been used to play the game. The
#
#def ticTacToe(numPlayers) accepts the number of players and simulates the
#ticTapToe, asking players to enter unused box numbers.
#
#def main() is the driver module that accepts the number of players from the user
# and calls the ticTacToe module
#Assignment: Complete the follwoing modules:
#checkCols
#checkRows
#checkDiagonal
#win
#Sample of the output is
#
#Project
#This game can be played by one or two players
#Enter the number of players, 1/2 for one/two players: 1
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | 9 |
#Player 0 Enter a box value: 9
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | O |
#Player 1 ***Computer*** playing
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 1
#
#The current TicTapToe Board
#| O | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 1 ***Computer*** playing
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 5
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | O | 6 |
#| 7 | X | O |
#Player 0 Wins
#Do you want to quit?
#Begin Program
#import random number generator
#from random library
#from random import randint, seed
#Global va.
#In this project you will write a program play TicTacToe #using tw.pdfaquapariwar
#In this project you will write a program play TicTacToe
#using two players (labels 0,1) or one play (label 0) playing with the machine (label 1).
#The TicTacToe board has 9 integers board = [1,2,3,4,5,6,7,8,9]. The following
# are the modules for the program
#
#def reset() resets the board to the original values
# board = [1,2,3,4,5,6,7,8,9]
#
#def printBoard() print the current state of the board using the format
#
#The current TicTacToe Board
# | 1 | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#
#The current TicTacToe Board
# | X | 2 | 3 |
# | 4 | 5 | 6 |
# | 7 | O | 9 |
#Note from the above that player 0 and 1 have played numbers 8 and 1
#respectively and the board display O for player 0 and X from player 1
#
#def changeBoard(num1, player) using the chosen box number to change
#the value of the box to 0 or -1 depending on whether the player is 0 or 1,
#respectively.
#
#def play(player) prints the player number (0 or 1) and prompts the player
# to enter a box value that have not changed to \'O\' or \'X\'
#
#def checkRows(value) checks to see which of the rows of the board
# has the same value and returns True, otherwise, returns False
#
#def checkCols(value) checks to see which of the cols of the board
# has the same value and returns True, otherwise, returns False
#
#def checkDiagonal(value) checks to see which of the diagonals of the board
# has the same value and returns True, otherwise, returns False
#
#def win(player) checks if a player wins the game, returns True of the player wins
# and False otherwise
#
#def machinePlay(player) plays the role of the player using random number.
# this function generates numbers in the interval [1,9] and uses the first
# generated random number that has not been used to play the game. The
#
#def ticTacToe(numPlayers) accepts the number of players and simulates the
#ticTapToe, asking players to enter unused box numbers.
#
#def main() is the driver module that accepts the number of players from the user
# and calls the ticTacToe module
#Assignment: Complete the follwoing modules:
#checkCols
#checkRows
#checkDiagonal
#win
#Sample of the output is
#
#Project
#This game can be played by one or two players
#Enter the number of players, 1/2 for one/two players: 1
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | 9 |
#Player 0 Enter a box value: 9
#
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | 8 | O |
#Player 1 ***Computer*** playing
#The current TicTapToe Board
#| 1 | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 1
#
#The current TicTapToe Board
#| O | 2 | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 1 ***Computer*** playing
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | 5 | 6 |
#| 7 | X | O |
#Player 0 Enter a box value: 5
#
#The current TicTapToe Board
#| O | X | 3 |
#| 4 | O | 6 |
#| 7 | X | O |
#Player 0 Wins
#Do you want to quit?
#Begin Program
#import random number generator
#from random library
#from random import randint, seed
#Global va.
public interface Game Note interface in place of class { .pdfkavithaarp
public interface Game // Note *interface* in place of *class*
{
/// play the game and return the final score
/// where a higher score should be better,
/// and a negative score is allowed.
int play(); // Note semicolon in place of a body
// You can have multiple method headings declared
}
--------------------------------------------------------------------------------------------------------------
import java.util.*;
/// Starting point for Interface Lab.
public class PlayGames
{
private static Scanner in;
private static Random rand = new Random();
private static int gameCount = 0;
public static Game popRandom(Game[] g)
{
int n = gameCount;
int i = rand.nextInt(n);
Game ret = g[i];
g[i] = g[n-1];
gameCount--;
return ret;
}
public static void main(String[] args)
{
Game[] games = new Game[10]; // Note Game as a type
games[gameCount] = new AdditionGame(rand, 100);
gameCount++; // next index to put a Game at
// write at least 2 more different types of Game classes
// and add a new one of each type to games
// ...
in = new Scanner(System.in);
int totScore = 0;
do {
Game g = popRandom(games);
totScore += g.play(); // use numerical result from the game
} while (gameCount > 0 && agree(\"Want a game? \"));
System.out.println(\"Thanks for Playing!\");
System.out.println(\"Your total score is \" + totScore);
}
public static boolean agree(String prompt)
{
System.out.print(prompt);
String input = in.next();
if (input.equalsIgnoreCase(\"y\")) return true;
return false;
}
--------------------------------------------------------------------------------------------------------------------
--
import java.util.*;
public class AdditionGame implements Game // note implements!!
{
private Random rand;
private int n;
// Constructor for objects of class AdditionGame
public AdditionGame(Random r, int big)
{
rand = r;
n = big;
}
// play all games and keep score.
public int play() // exactly matches heading in Game interface
{
final int numGames = 3;
Scanner in = new Scanner(System.in);
int score = 0;
System.out.println(\"Welcome to the addition game! We\'ll now play \" + numGames
+ \" rounds.\");
for (int i = 0; i < numGames; i++) {
int x = rand.nextInt(n), y = rand.nextInt(n), ans = x+y;
System.out.print(String.format(\"Enter the sum: %d + %d = \", x, y));
int val = in.nextInt();
if (ans == val) {
System.out.println(\"Correct!\");
score++;
}
else
System.out.println(\"Wrong! Right answer is \" + ans);
}
System.out.println(\"Thanks for playing the addition game. Your score is \" + score +
\".\");
System.out.println();
return score;
}
}
--------------------------------------------------------------------------------------------------------------------
---
Create two classes that implement a Game interface:
------------------------------------
There is a Game interface defined, and also a PlayGames class that uses objects from classes that
implement that interface. The Game interface declares a single abstract method play that returns
an int, the score from playing the gam.
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
Java Programming
Implement an auction application with the following features/functionality:
Inputs for an item and minimum bid amount.
Inputs for bidder name, bid amount and maximum bid. You will implement a class called Bid to
hold this information.
Label controls to show the current high bidder’s name, bid amount and maximum bid. For bid
amounts, you may assume all bids will be a whole dollar value just to simplify things a bit.
A list box to show all entries when the auction is over. You will use the pop() method to retrieve
each bid off the stack and display it. This feature is intended more for test/debug purposes.
You will implement a Stack class that will keep the highest bid at the top of the stack. It must
have the classic stack operations of push() to place an item on the stack, pop() to remove the top
item from the stack, and top() to view the top item on the stack but not remove it. You may use a
linked list of your own design, an array, or the built-in Java Array List or Linked List classes as
the underlying data structure. You may also add an item count property if you want.
The auction will work by the following rules:
When the initial bid is made, it must be greater than or equal to the item’s minimum bid amount
to be placed on the stack.
When another bid is made that is greater than the current high bidder’s maximum bid, that bid
will be pushed to the top of the stack and become the new highest bid.
If another bid is made that is greater than the current high bid but less than or equal to the
current high bidder’s maximum amount, the current high bidder’s bid will be raised to match but
the new bid will not be placed on the stack.
Your application should have a message box or label to indicate the status of the bid operation.
There is no limit on the number of bids.
Solution
// To import features as \'Panel, Button, Label, TextArea, TextField, Color\', etc.
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
// In this program, \"this.\" is used instead of \"this.getContentPane().\" in Auction.init() uses;
class Bidacution
{
public static void main (String[] args)
{ Frame gameapp = new Frame (\"AUCTION by Henry C. Joy\");
gameapp.setSize (750, 560); // larger than actual applet -- allow for edges
gameapp.addWindowListener (new WindowCloser());
Auction display = new Auction();
display.init();
gameapp.add (display);
gameapp.setVisible (true);
}
private static class WindowCloser extends java.awt.event.WindowAdapter
{ public void windowClosing (java.awt.event.WindowEvent e)
{ System.exit (0);
}}
}
// The MAIN method of the software (the init method): using 20 + classes.
public class Auction extends java.applet.Applet // every Applet is a Panel
{
public static final int UNIT = 5; // difference between 2 consec. bids
public static final int BREAK = 5; // separate first 5 from last 4
public static final String REPEAT = \"repeat game\";
// VIEW objects
private Panel boardPanel = new Panel();
p.
Need help writing the code for a basic java tic tac toe game Tic.pdfhainesburchett26321
Need help writing the code for a basic java tic tac toe game
// Tic-Tac-Toe: Complete the FIX-ME\'s to have a working version of Tic-Tac-Toe.
// Note: the basis of the game is a two-dimensional \'board\' array, with 3 rows
// and 3 columns. A value of +1 indicates an \'X\' on the board; and a value of
// -1 indicates an \'O\'
// Group Member names:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.*;
public class TicTacToe implements ActionListener{
// FIX ME #5: set CPU_PAUSE to true when ready to play
final boolean CPU_PAUSE = true; // does the CPU pause to think?
JButton [][] buttons = new JButton[3][3];
int [][] board = new int[3][3];
JLabel status = new JLabel(\"Player\'s turn\", JLabel.CENTER);
JFrame frame = new JFrame();
JPanel buttonPanel = new JPanel();
JPanel labelPanel = new JPanel();
Timer timer = null;
// draw X or O depending on \'x\' values
void refresh(int [][] x) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (x[i][j] == 1) {
buttons[i][j].setForeground(Color.blue);
buttons[i][j].setText(\"X\");
} else if (x[i][j] == -1) {
buttons[i][j].setForeground(Color.pink);
buttons[i][j].setText(\"O\");
} else {
buttons[i][j].setText(\" \");
}
}
}
}
boolean have_winner(int checkVal) {
boolean winner = false;
// FIX ME #1: if there are three \'checkVal\' values in-a-row across,
// then set \'winner\' to true
// FIX ME #2: if there are three \'checkVal\' values in-a-row vertically,
// then set \'winner\' to true
int checkSum = 0;
if (checkSum == 3 * checkVal){
winner = true;
}
// FIX ME #3: if there are three \'checkVal\' values in-a-row diagonally,
// then set \'winner\' to true
return winner;
}
boolean playerMove(ActionEvent e) {
JButton btn = (JButton) e.getSource();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (btn.equals(buttons[i][j])) {
if (board[i][j] != 0) {
return false;
}
board[i][j] = 1;
refresh(board);
return true;
}
}
}
return false;
}
boolean board_is_full() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (board[i][j] == 0) return false;
}
}
return true;
}
ActionListener refreshListener = new ActionListener(){
int delayCount = 0;
public void actionPerformed(ActionEvent event){
delayCount++;
if (delayCount > 5) {
delayCount = 0;
timer.stop();
enableButtons(false);
}
if (delayCount % 2 == 0) {
refresh(board);
} else {
int [][] x = new int[3][3];
refresh(x);
}
}
};
void enableButtons(boolean enable) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
buttons[i][j].setEnabled(enable);
}
}
}
ActionListener computerMove = new ActionListener(){
public void actionPerformed(ActionEvent event){
/* FIX ME #4: The computer moves by placing an \'O\' on the board
* (i.e.), assigning a -1 to a valid element of the board array
* The computer can play randomly, by randomly selecting a
* row and column to play .
#include <iostream>
#include <fstream>
#include "Opening.h"
#include "Game.h"
#include <stdlib.h>
using namespace std;
int GetNumOpenings();
void CompareOpenings(Opening openings[], int numOpenings);
string DetectOpening(Game *game, Opening opening);
string GetString();
void Menu();
void ReadOpenings(Opening arr[], int size);
void PrintOpenings(Opening arr[], int size);
int main()
{
Menu();
return 0;
}
void Menu(){
int numOpenings = 0;
numOpenings = GetNumOpenings();
Opening openings[numOpenings];
ReadOpenings(openings, numOpenings);
while(true){
int action;
cout<<"Print Stored Openings (1)"<<endl;
cout<<"Load Game File (2)"<<endl;
cout<<"Exit (0)"<<endl<<endl;
cout<<"Enter action:";
cin>>action;
cin.ignore();
cout<<endl;
switch(action){
case 0:
cout<<"Exit Selected"<<endl;
break;
case 1:
PrintOpenings(openings, numOpenings);
break;
case 2:
CompareOpenings(openings, numOpenings);
break;
default:
cout<<"Invalid Action"<<endl;
}
if(action == 0)
break;
}
}
string GetString(){
string filename;
cout<<"Please enter game filename:";
cin>>filename;
cin.ignore();
return filename;
}
int GetNumOpenings(){
ifstream infile;
infile.open("openings.txt");
int numOpenings;
infile>>numOpenings;
infile.close();
return numOpenings;
}
void CompareOpenings(Opening openings[], int numOpenings){
//FILL IN
}
string DetectOpening(Game *game, Opening opening){
//FILL IN
//remove this return statement
return " ";
}
void PrintOpenings(Opening arr[], int size){
//FILL IN
}
void ReadOpenings(Opening arr[], int size){
//FILL IN
}
B
26
e4 e5 Nf3 Nc6 Bc4 Nf6 d3 Bc5
g3 Ng4 a3 Bxf2+ Ke2 a6 Ng5 Nd4+
Kf1 Qf6 b4 Be3+ Kg2 Qf2+ Kh3 d5
Rg1 Qxh2#
W
15
e4 e5 Nf3 Nc6 Bc4 d6 Ng5 a6
Bxf7+ Kd7 Nc3 b5 Qg4+ Ke7 Nd5#
B
35
e4 e5 Bc4 Nc6 Nf3 Bc5 c3 Nf6
h3 Nxe4 d4 d5 Bb3 exd4 Nbd2 Nxf2
e2+ Qe7 Qxe7+ Nxe7 Kxf2 dxc3+ Kf1 Nf5
bxc3 Ng3+ Ke1 Nxh1 Bxd5 O-O g4 Nf2
Rb1 c6 Bc4
Objective: The main objective of this assignment is checking the students’ ability to work with ADTs. In this week's assignment, you will be writing the interface of an ADT in order to conform to the requirements of a larger application.
Description: You have been tasked with implementing a program that can read chess games from a file and detect whether the initial moves (opening) matches any of the stored openings (also read from a file). Note that the program does not compile successfully as it is missing ADT definitions which you will implement.
For example, the position in Figure 1, which corresponds to the first 5 moves, is called the “Italian Game”.
Figure 1.
Connect4.c2. Include the string.h header file3. Declare the foll.pdfshakilaghani
Connect4.c
2. Include the string.h header file
3. Declare the following macros (i.e., use #define NOT const) to use
as global constants for the application
a. ROW with a value of 6
b. COL with a value of 7
c. ONE with a value of 1
d. TWO with a value of 2
e. SPACE with a value of ' ' (NOTE: there is an explicit
space between the open and close single quote)
f. TRUE with a value of 1
g. FALSE with a value of 0
4. Write the function declaration or prototype for functions
a. initializeBoard
b. displayBoard
c. makeMove
5. Update function playGame to do the following
a. Add local variable named board, data type character,
two-dimensional array, size 6 rows and 7 columns (i.e.,
use macros ROW and COL)
b. Before the while loop
i. Call function initializeBoard; pass as an argument
array board
c. Inside the while loop
i. Comment out or delete call to function
displayExplicitBoard
ii. Call function displayBoard; pass as an argument
array board
iii. Inside the if/else if statements
1. Replace the printf statement notifying the
player it is their turn with call to function
makeMove; pass as arguments
a. Character array of players name
(i.e., yellow or red)
b. 2-d array board
6. Write function initializeBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Set the element at the current row and column in
the 2-d array board to an explicit space (i.e., use
macro SPACE)
7. Write function displayBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write printf statements to display the top row of the
Connect Four board
d. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Write a printf statement to display the value
stored in the current element of the array board
8. Write function makeMove to do the following
d. Return type void
e. Parameter list includes
i. Character array for the players name (i.e.,
playerName, size is 20, use macro NAME)
ii. 2-d character array (i.e., board), size 6 rows and 7
columns (i.e., use macros ROW and COL)
f. Declare variable to store the user input for their move,
data type character array, size 2 (i.e., move, use macro
TWO)
g. Declare variable to store if player move is valid, data type
integer, initialize to 0 (i.e., valid, use macro FALSE)
h. Loop while the players move input is not valid (i.e.,
FALSE)
i. Write a printf statement to prompt the player to
enter their move
ii. Write a scanf statement to store the players move
in local variable move
iii. Write a printf statement to display to the player
the move they entered
iv. Declare variable to store the length of the players
move input, data type integer (i.e., length) set
equal to explicit type ca.
Hello!This is Java assignment applet.Can someone help me writing.pdfjyothimuppasani1
Hello!
This is Java assignment applet.
Can someone help me writing a code how to exit the game when I press no in question( would
you like to play again?). Also if no one wins or draws i would like to pop up the question ( would
you like to play again?). I have the code below i would like someone to add it
Thanks in advance!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TicTacToe extends Applet implements ActionListener{
// Array to store buttons
JButton button[][] = new JButton[3][3];
boolean isNewGame =false;
// To switch player either X or O
boolean isZero = true; //first turn is always 0
// Setup size
// Set layout to grid
// Create buttons through loop
// Add buttons to layout
// Add listener
public void init(){
setSize(500, 500);
setLayout(new GridLayout(3,3));
// if it is not a new game
if(isNewGame==false) {
// Adding buttons to layout
//initialize the Grid and add ActionListener to each Button
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
// init jButton
button[i][j] = new JButton(\"\");
// Setup Font and Size here
button[i][j].setFont(new Font(\"Lucida Grande\", Font.PLAIN, 28));
// Add is a method from applet to add buttons in layout
add(button[i][j]);
// Listener
button[i][j].addActionListener(this);
}
}
}
else {
// If we need to restart the game, then we only set text to empty
// Back to black color
// add listener
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
button[i][j].setText(\"\");
button[i][j].setForeground(Color.BLACK);
button[i][j].removeActionListener(this);
button[i][j].addActionListener(this);
}
}
}
}
// Go all the buttons in arrsy
// Check the event with button in array
// if player O is true, set button text O. Otherwise. X
// Remove Listerner. Why? only once you can click
// Change player by isZero
// Check for winner
public void actionPerformed(ActionEvent event){
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++){
if((event.getSource() == button[i][j])){
if(isZero){
button[i][j].setText(\"O\");
}
else{
button[i][j].setText(\"X\");
}
button[i][j].removeActionListener(this); //you cannot click on one tile more than
once
isZero = !isZero;
checkForWinners(); //check if any winner after each move
}
}
}
public void checkForWinners(){
//3 horizontal lines
for(int i = 0; i < 3; i++){
if(button[i][0].getText().equals(button[i][1].getText())
&& button[i][1].getText().equals(button[i][2].getText())
&& !button[i][0].getText().equals(\"\")){
String player = button[i][0].getText();
button[i][0].setForeground(Color.RED);
button[i][1].setForeground(Color.RED);
button[i][2].setForeground(Color.RED);
int reply =JOptionPane.showConfirmDialog(null, player + \" wins!\"+\"\ Would like
to play again?\",\"Game over\",JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
isNewGame = true;
init();
return;
}
else {
System.exit(0);
return;
}
}
}
//3 vertical lines
for(int i = 0; i < 3; i++){
if(button[0][i].getText().equals(button[1][i].getText())
&& .
An introduction and explanation of human factors and sociotechnical .pdfmanjan6
An introduction and explanation of human factors and sociotechnical issues in medical
informatics
Solution
Healthcare is arguably the most complex of the complex,sociotechnical systems studied by the
human factors community .This complexity only looks to increase over the next five years as
massive changes in how care is delivered and re-imbursed are already underway.Not the least of
these changes is the not-so-subtle introduction of medical informatics and their corresponding
ripple effects on how the roles are designed,how work is co-ordinated,how primary and more
distant personnel are impacted and how power is allocated within the groups.Much of the
activity in medical informatics is conducted without the representation of human factors ,or even
without the knowledge of what human factors can contribute other than usable testing methods..
Astronomers were able to find a new planet in a far away solar system.pdfmanjan6
Astronomers were able to find a new planet in a far away solar system. They are calling this
planet Nova, for the presence of abundant dements from a supernova. The people of planet Nova
speak in a strange language. Thankfully, a scientist was able to decode their language to English.
He found that they also use the same letters as English, but they swap each pair of consecutive
alphabets in English. For example, they swap A with B and Y with Z. Create a function that
reads a word in Nova and translates it into English.
Solution
def nova(st):
st = list(st)
for i in range(0,len(st)):
if st[i] == \'z\':
st[i] = \'a\'
elif st[i] == \'Z\':
st[i] = \'A\'
else:
st[i] = chr(ord(st[i])+1)
return \'\'.join(str(i) for i in st).
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdfmanjan6
5. If we found AB+ blood at a crime scene and we knew one of our 5 suspects had a partial
Genotype that was determined to be IAI B CcEe would this be enough evidence to make this
suspect now a lead suspect. Why or Why not? Use Punnett squares to make your case. What
additional test would need to be performed?
6. A homicidal maniac has a genotype of IB I B Ccddeehhsese. At this murderer’s most recent
crime scene we find the murder’s baseball cap without blood, a pair of stained underwear no
blood, no fingerprints, no fibers, no hairs. Based on these items, do we have any possible
chemical, or immunological or other analyses we can perform that will identify the murderer as it
relates to the genotypic info we have on him or her. If so how would you go about doing those
studies
Solution
5. ANS:
No, At first the D antigen additional test would need to be performed. It is because AB+ is the
most common blood group and the the perp would have to be either Dd or DD (Rh+ve). we
could only really use the evidence to exclude suspects.
6. ANS:
In this case the blood strains are not there. Genetic material on it and use that to identify the
genotype is the best way to detects suspect. So genotyping performing will identify the murderer.
Genotype is used to determine the alleles that an individual possesses. Genotyping test is used
for crime and paternity testing because in genome there is 1 difference present in every 1,000
base pairs (in humans 3,000,000 difference sequence are present)..
All of the following individuals are U.S. residents Kelly (27.pdfmanjan6
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
Solution
According to the law passes in April,\"Parent paying child support
Sydnee is entitled to do so.
Blossom Company had these transactions during the current period..pdfmanjan6
Blossom Company had these transactions during the current period.
Nov. 28June 12Issued 78,000 shares of $1 par value common stock for cash of $292,500.July
11Issued 2,500 shares of $100 par value preferred stock for cash at $104 per share.
Nov. 28Purchased 1,000 shares of treasury stock for $7,100. Prepare a tabular summary to record
the Blossom Company transactions. (Ifa transaction causes a decrease in Assets, Liabilities or
Stockholders\' Equity, place a negative sign (or parentheses) in front of the amount entered for
the particular Asset, Liability or Equity item that was reduced.) Assets Liabilities Stockholders\'
Equity Paid-in-Capital Retained Earnings Cash +Common Stock+ PIC in Excess of Pa +Pref.
Stock + + Revenue ExpenseDividend Com. Pref June 22 July 11 Nov. 28
Solution
Cash Liabilities Common stock PIC in excess of par Com. Pref. stock PIC in excess of par
Pref. Treasury stock Revenue Expenses Dividend 22-Jun 292500 78000 214500 11-Jul
260000 250000 10000 28-Nov -7100 -7100.
Using the case study below, develop a written report of your market .pdfmanjan6
Using the case study below, develop a written report of your market analysis. Include a visual
diagram of your overall market analysis use of strategic thinking maps (see diagram in the
Module) as a tool to assist with the different facets of the strategic planning process.
The map is to be used as a supplement for your written market analysis. The market analysis
produced will be used in the final submission of your Capstone Project.
Your well-written market analysis should meet the following requirements:
Be 3-4 pages in length, not including the cover, abstract (optional), or reference pages.
Utilize headings to organize the content.
Include the strategic thinking map in addition to/or as a part of the 3-4 pages of content.
Include a minimum of four references with associated in-text citations.
The circumstances in Pocahontas County resonate in many rural communities across the country:
• A depressed local economy
• Substantial barriers to health access
• Difficulty in attracting health professionals.
Portrait of Pocahontas County
Pocahontas County is located in the southeast region of West Virginia. The county has a total of
942 square miles and is the site of the head waters for eight rivers: Cherry River, Cranberry
River, Elk River, Ganley River, Greenbriar River, Tygart Valley River, Williams River, and
Shaver Fork of the Cheat River. Pocahontas County consists of the following towns: Arborale,
Bartow, Buckeye, Cass, Dunmore, Durbin, Greenbank, Hillsboro, Marlington, and Slatyfork.
As of the 2010 Census there are 9,131 people residing in Pocahontas County. The racial makeup
is 98% Caucasian, .78% African American, .43% Hispanic, .14% Asian, and .07% Native
American. The median income for a household within the county is $26,401.
Access to Health Services
Pocahontas County has a shortage of healthcare providers. There is one hospital, Pocahontas
Memorial Hospital, and one nursing home, Pocahontas Center. The ratio for dentists is 8,851 to
1. The ratio for primary care physicians is 8508 to 1 (County Health Roadmaps & Rankings,
n.d.). The county’s physician-to-population ratio is significantly higher than the Unites States
overall ratio.
Pocahontas Memorial Hospital is a 25-bed, level-4 trauma center. A rural health clinic is located
within the hospital. The health clinic offers laboratory services, immunizations, disease
management, and monthly specialty clinics (cardiology, podiatry, and nephrology).
For more information about Pocahontas Memorial Hospital, visit the following website:
http://www.pmhwv.org/
Solution
Health care Limitations
Executive summary
The health care industry which is also known as the health economy or the medical industry is a
broad industry which specializes in the delivery of services regarding treatment of diseases,
conducting diagnostic services and therapies to identify various diseases so at to understand the
kind of treatment to be subjected to such diseases (World Health Organization. (2002). the
industr.
Which of the following is NOT a characteristic of a plasmid used as .pdfmanjan6
Which of the following is NOT a characteristic of a plasmid used as a cloning vector?
A. contains a selection marker.
B. contains an origin of replication.
C. has a site for inserting foreign DNA.
D. integrates into the host chromosome.
E. has lacZ gene at the insertion site
Solution
D. integrates into the host chromosome.
a vector is a DNA molecule that is used as a vehivle for the introduction of foreign genetic
material in the cell.Most commonly used vectors are plasmids,cosnids,viral vectors.Some
features that are common to all vectors are origin of replication,multicloning site and a selectable
marker system.A vector replicates autonomously irrespective of the replication of host DNA.A
vector does not integrate into the host chromosome..
More Related Content
Similar to Please help with this. program must be written in C# .. All of the g.pdf
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
Java Programming
Implement an auction application with the following features/functionality:
Inputs for an item and minimum bid amount.
Inputs for bidder name, bid amount and maximum bid. You will implement a class called Bid to
hold this information.
Label controls to show the current high bidder’s name, bid amount and maximum bid. For bid
amounts, you may assume all bids will be a whole dollar value just to simplify things a bit.
A list box to show all entries when the auction is over. You will use the pop() method to retrieve
each bid off the stack and display it. This feature is intended more for test/debug purposes.
You will implement a Stack class that will keep the highest bid at the top of the stack. It must
have the classic stack operations of push() to place an item on the stack, pop() to remove the top
item from the stack, and top() to view the top item on the stack but not remove it. You may use a
linked list of your own design, an array, or the built-in Java Array List or Linked List classes as
the underlying data structure. You may also add an item count property if you want.
The auction will work by the following rules:
When the initial bid is made, it must be greater than or equal to the item’s minimum bid amount
to be placed on the stack.
When another bid is made that is greater than the current high bidder’s maximum bid, that bid
will be pushed to the top of the stack and become the new highest bid.
If another bid is made that is greater than the current high bid but less than or equal to the
current high bidder’s maximum amount, the current high bidder’s bid will be raised to match but
the new bid will not be placed on the stack.
Your application should have a message box or label to indicate the status of the bid operation.
There is no limit on the number of bids.
Solution
// To import features as \'Panel, Button, Label, TextArea, TextField, Color\', etc.
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
// In this program, \"this.\" is used instead of \"this.getContentPane().\" in Auction.init() uses;
class Bidacution
{
public static void main (String[] args)
{ Frame gameapp = new Frame (\"AUCTION by Henry C. Joy\");
gameapp.setSize (750, 560); // larger than actual applet -- allow for edges
gameapp.addWindowListener (new WindowCloser());
Auction display = new Auction();
display.init();
gameapp.add (display);
gameapp.setVisible (true);
}
private static class WindowCloser extends java.awt.event.WindowAdapter
{ public void windowClosing (java.awt.event.WindowEvent e)
{ System.exit (0);
}}
}
// The MAIN method of the software (the init method): using 20 + classes.
public class Auction extends java.applet.Applet // every Applet is a Panel
{
public static final int UNIT = 5; // difference between 2 consec. bids
public static final int BREAK = 5; // separate first 5 from last 4
public static final String REPEAT = \"repeat game\";
// VIEW objects
private Panel boardPanel = new Panel();
p.
Need help writing the code for a basic java tic tac toe game Tic.pdfhainesburchett26321
Need help writing the code for a basic java tic tac toe game
// Tic-Tac-Toe: Complete the FIX-ME\'s to have a working version of Tic-Tac-Toe.
// Note: the basis of the game is a two-dimensional \'board\' array, with 3 rows
// and 3 columns. A value of +1 indicates an \'X\' on the board; and a value of
// -1 indicates an \'O\'
// Group Member names:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.*;
public class TicTacToe implements ActionListener{
// FIX ME #5: set CPU_PAUSE to true when ready to play
final boolean CPU_PAUSE = true; // does the CPU pause to think?
JButton [][] buttons = new JButton[3][3];
int [][] board = new int[3][3];
JLabel status = new JLabel(\"Player\'s turn\", JLabel.CENTER);
JFrame frame = new JFrame();
JPanel buttonPanel = new JPanel();
JPanel labelPanel = new JPanel();
Timer timer = null;
// draw X or O depending on \'x\' values
void refresh(int [][] x) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (x[i][j] == 1) {
buttons[i][j].setForeground(Color.blue);
buttons[i][j].setText(\"X\");
} else if (x[i][j] == -1) {
buttons[i][j].setForeground(Color.pink);
buttons[i][j].setText(\"O\");
} else {
buttons[i][j].setText(\" \");
}
}
}
}
boolean have_winner(int checkVal) {
boolean winner = false;
// FIX ME #1: if there are three \'checkVal\' values in-a-row across,
// then set \'winner\' to true
// FIX ME #2: if there are three \'checkVal\' values in-a-row vertically,
// then set \'winner\' to true
int checkSum = 0;
if (checkSum == 3 * checkVal){
winner = true;
}
// FIX ME #3: if there are three \'checkVal\' values in-a-row diagonally,
// then set \'winner\' to true
return winner;
}
boolean playerMove(ActionEvent e) {
JButton btn = (JButton) e.getSource();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (btn.equals(buttons[i][j])) {
if (board[i][j] != 0) {
return false;
}
board[i][j] = 1;
refresh(board);
return true;
}
}
}
return false;
}
boolean board_is_full() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (board[i][j] == 0) return false;
}
}
return true;
}
ActionListener refreshListener = new ActionListener(){
int delayCount = 0;
public void actionPerformed(ActionEvent event){
delayCount++;
if (delayCount > 5) {
delayCount = 0;
timer.stop();
enableButtons(false);
}
if (delayCount % 2 == 0) {
refresh(board);
} else {
int [][] x = new int[3][3];
refresh(x);
}
}
};
void enableButtons(boolean enable) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
buttons[i][j].setEnabled(enable);
}
}
}
ActionListener computerMove = new ActionListener(){
public void actionPerformed(ActionEvent event){
/* FIX ME #4: The computer moves by placing an \'O\' on the board
* (i.e.), assigning a -1 to a valid element of the board array
* The computer can play randomly, by randomly selecting a
* row and column to play .
#include <iostream>
#include <fstream>
#include "Opening.h"
#include "Game.h"
#include <stdlib.h>
using namespace std;
int GetNumOpenings();
void CompareOpenings(Opening openings[], int numOpenings);
string DetectOpening(Game *game, Opening opening);
string GetString();
void Menu();
void ReadOpenings(Opening arr[], int size);
void PrintOpenings(Opening arr[], int size);
int main()
{
Menu();
return 0;
}
void Menu(){
int numOpenings = 0;
numOpenings = GetNumOpenings();
Opening openings[numOpenings];
ReadOpenings(openings, numOpenings);
while(true){
int action;
cout<<"Print Stored Openings (1)"<<endl;
cout<<"Load Game File (2)"<<endl;
cout<<"Exit (0)"<<endl<<endl;
cout<<"Enter action:";
cin>>action;
cin.ignore();
cout<<endl;
switch(action){
case 0:
cout<<"Exit Selected"<<endl;
break;
case 1:
PrintOpenings(openings, numOpenings);
break;
case 2:
CompareOpenings(openings, numOpenings);
break;
default:
cout<<"Invalid Action"<<endl;
}
if(action == 0)
break;
}
}
string GetString(){
string filename;
cout<<"Please enter game filename:";
cin>>filename;
cin.ignore();
return filename;
}
int GetNumOpenings(){
ifstream infile;
infile.open("openings.txt");
int numOpenings;
infile>>numOpenings;
infile.close();
return numOpenings;
}
void CompareOpenings(Opening openings[], int numOpenings){
//FILL IN
}
string DetectOpening(Game *game, Opening opening){
//FILL IN
//remove this return statement
return " ";
}
void PrintOpenings(Opening arr[], int size){
//FILL IN
}
void ReadOpenings(Opening arr[], int size){
//FILL IN
}
B
26
e4 e5 Nf3 Nc6 Bc4 Nf6 d3 Bc5
g3 Ng4 a3 Bxf2+ Ke2 a6 Ng5 Nd4+
Kf1 Qf6 b4 Be3+ Kg2 Qf2+ Kh3 d5
Rg1 Qxh2#
W
15
e4 e5 Nf3 Nc6 Bc4 d6 Ng5 a6
Bxf7+ Kd7 Nc3 b5 Qg4+ Ke7 Nd5#
B
35
e4 e5 Bc4 Nc6 Nf3 Bc5 c3 Nf6
h3 Nxe4 d4 d5 Bb3 exd4 Nbd2 Nxf2
e2+ Qe7 Qxe7+ Nxe7 Kxf2 dxc3+ Kf1 Nf5
bxc3 Ng3+ Ke1 Nxh1 Bxd5 O-O g4 Nf2
Rb1 c6 Bc4
Objective: The main objective of this assignment is checking the students’ ability to work with ADTs. In this week's assignment, you will be writing the interface of an ADT in order to conform to the requirements of a larger application.
Description: You have been tasked with implementing a program that can read chess games from a file and detect whether the initial moves (opening) matches any of the stored openings (also read from a file). Note that the program does not compile successfully as it is missing ADT definitions which you will implement.
For example, the position in Figure 1, which corresponds to the first 5 moves, is called the “Italian Game”.
Figure 1.
Connect4.c2. Include the string.h header file3. Declare the foll.pdfshakilaghani
Connect4.c
2. Include the string.h header file
3. Declare the following macros (i.e., use #define NOT const) to use
as global constants for the application
a. ROW with a value of 6
b. COL with a value of 7
c. ONE with a value of 1
d. TWO with a value of 2
e. SPACE with a value of ' ' (NOTE: there is an explicit
space between the open and close single quote)
f. TRUE with a value of 1
g. FALSE with a value of 0
4. Write the function declaration or prototype for functions
a. initializeBoard
b. displayBoard
c. makeMove
5. Update function playGame to do the following
a. Add local variable named board, data type character,
two-dimensional array, size 6 rows and 7 columns (i.e.,
use macros ROW and COL)
b. Before the while loop
i. Call function initializeBoard; pass as an argument
array board
c. Inside the while loop
i. Comment out or delete call to function
displayExplicitBoard
ii. Call function displayBoard; pass as an argument
array board
iii. Inside the if/else if statements
1. Replace the printf statement notifying the
player it is their turn with call to function
makeMove; pass as arguments
a. Character array of players name
(i.e., yellow or red)
b. 2-d array board
6. Write function initializeBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Set the element at the current row and column in
the 2-d array board to an explicit space (i.e., use
macro SPACE)
7. Write function displayBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write printf statements to display the top row of the
Connect Four board
d. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Write a printf statement to display the value
stored in the current element of the array board
8. Write function makeMove to do the following
d. Return type void
e. Parameter list includes
i. Character array for the players name (i.e.,
playerName, size is 20, use macro NAME)
ii. 2-d character array (i.e., board), size 6 rows and 7
columns (i.e., use macros ROW and COL)
f. Declare variable to store the user input for their move,
data type character array, size 2 (i.e., move, use macro
TWO)
g. Declare variable to store if player move is valid, data type
integer, initialize to 0 (i.e., valid, use macro FALSE)
h. Loop while the players move input is not valid (i.e.,
FALSE)
i. Write a printf statement to prompt the player to
enter their move
ii. Write a scanf statement to store the players move
in local variable move
iii. Write a printf statement to display to the player
the move they entered
iv. Declare variable to store the length of the players
move input, data type integer (i.e., length) set
equal to explicit type ca.
Hello!This is Java assignment applet.Can someone help me writing.pdfjyothimuppasani1
Hello!
This is Java assignment applet.
Can someone help me writing a code how to exit the game when I press no in question( would
you like to play again?). Also if no one wins or draws i would like to pop up the question ( would
you like to play again?). I have the code below i would like someone to add it
Thanks in advance!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TicTacToe extends Applet implements ActionListener{
// Array to store buttons
JButton button[][] = new JButton[3][3];
boolean isNewGame =false;
// To switch player either X or O
boolean isZero = true; //first turn is always 0
// Setup size
// Set layout to grid
// Create buttons through loop
// Add buttons to layout
// Add listener
public void init(){
setSize(500, 500);
setLayout(new GridLayout(3,3));
// if it is not a new game
if(isNewGame==false) {
// Adding buttons to layout
//initialize the Grid and add ActionListener to each Button
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
// init jButton
button[i][j] = new JButton(\"\");
// Setup Font and Size here
button[i][j].setFont(new Font(\"Lucida Grande\", Font.PLAIN, 28));
// Add is a method from applet to add buttons in layout
add(button[i][j]);
// Listener
button[i][j].addActionListener(this);
}
}
}
else {
// If we need to restart the game, then we only set text to empty
// Back to black color
// add listener
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
button[i][j].setText(\"\");
button[i][j].setForeground(Color.BLACK);
button[i][j].removeActionListener(this);
button[i][j].addActionListener(this);
}
}
}
}
// Go all the buttons in arrsy
// Check the event with button in array
// if player O is true, set button text O. Otherwise. X
// Remove Listerner. Why? only once you can click
// Change player by isZero
// Check for winner
public void actionPerformed(ActionEvent event){
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++){
if((event.getSource() == button[i][j])){
if(isZero){
button[i][j].setText(\"O\");
}
else{
button[i][j].setText(\"X\");
}
button[i][j].removeActionListener(this); //you cannot click on one tile more than
once
isZero = !isZero;
checkForWinners(); //check if any winner after each move
}
}
}
public void checkForWinners(){
//3 horizontal lines
for(int i = 0; i < 3; i++){
if(button[i][0].getText().equals(button[i][1].getText())
&& button[i][1].getText().equals(button[i][2].getText())
&& !button[i][0].getText().equals(\"\")){
String player = button[i][0].getText();
button[i][0].setForeground(Color.RED);
button[i][1].setForeground(Color.RED);
button[i][2].setForeground(Color.RED);
int reply =JOptionPane.showConfirmDialog(null, player + \" wins!\"+\"\ Would like
to play again?\",\"Game over\",JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
isNewGame = true;
init();
return;
}
else {
System.exit(0);
return;
}
}
}
//3 vertical lines
for(int i = 0; i < 3; i++){
if(button[0][i].getText().equals(button[1][i].getText())
&& .
Similar to Please help with this. program must be written in C# .. All of the g.pdf (15)
An introduction and explanation of human factors and sociotechnical .pdfmanjan6
An introduction and explanation of human factors and sociotechnical issues in medical
informatics
Solution
Healthcare is arguably the most complex of the complex,sociotechnical systems studied by the
human factors community .This complexity only looks to increase over the next five years as
massive changes in how care is delivered and re-imbursed are already underway.Not the least of
these changes is the not-so-subtle introduction of medical informatics and their corresponding
ripple effects on how the roles are designed,how work is co-ordinated,how primary and more
distant personnel are impacted and how power is allocated within the groups.Much of the
activity in medical informatics is conducted without the representation of human factors ,or even
without the knowledge of what human factors can contribute other than usable testing methods..
Astronomers were able to find a new planet in a far away solar system.pdfmanjan6
Astronomers were able to find a new planet in a far away solar system. They are calling this
planet Nova, for the presence of abundant dements from a supernova. The people of planet Nova
speak in a strange language. Thankfully, a scientist was able to decode their language to English.
He found that they also use the same letters as English, but they swap each pair of consecutive
alphabets in English. For example, they swap A with B and Y with Z. Create a function that
reads a word in Nova and translates it into English.
Solution
def nova(st):
st = list(st)
for i in range(0,len(st)):
if st[i] == \'z\':
st[i] = \'a\'
elif st[i] == \'Z\':
st[i] = \'A\'
else:
st[i] = chr(ord(st[i])+1)
return \'\'.join(str(i) for i in st).
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdfmanjan6
5. If we found AB+ blood at a crime scene and we knew one of our 5 suspects had a partial
Genotype that was determined to be IAI B CcEe would this be enough evidence to make this
suspect now a lead suspect. Why or Why not? Use Punnett squares to make your case. What
additional test would need to be performed?
6. A homicidal maniac has a genotype of IB I B Ccddeehhsese. At this murderer’s most recent
crime scene we find the murder’s baseball cap without blood, a pair of stained underwear no
blood, no fingerprints, no fibers, no hairs. Based on these items, do we have any possible
chemical, or immunological or other analyses we can perform that will identify the murderer as it
relates to the genotypic info we have on him or her. If so how would you go about doing those
studies
Solution
5. ANS:
No, At first the D antigen additional test would need to be performed. It is because AB+ is the
most common blood group and the the perp would have to be either Dd or DD (Rh+ve). we
could only really use the evidence to exclude suspects.
6. ANS:
In this case the blood strains are not there. Genetic material on it and use that to identify the
genotype is the best way to detects suspect. So genotyping performing will identify the murderer.
Genotype is used to determine the alleles that an individual possesses. Genotyping test is used
for crime and paternity testing because in genome there is 1 difference present in every 1,000
base pairs (in humans 3,000,000 difference sequence are present)..
All of the following individuals are U.S. residents Kelly (27.pdfmanjan6
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
All of the following individuals are U.S. residents: Kelly (27), her daughter Sydnee (4), and
Kelly\'s mother, June (50). All three lived together until the end of March, when Kelly moved
out. Then, in November, Kelly married Austin (29), and Sydnee moved in with Kelly and Austin,
who are filing a joint return. Sydnee does not pay over half the cost of her own support. If both
households try to claim Sydnee, who is entitled to do so?
Solution
According to the law passes in April,\"Parent paying child support
Sydnee is entitled to do so.
Blossom Company had these transactions during the current period..pdfmanjan6
Blossom Company had these transactions during the current period.
Nov. 28June 12Issued 78,000 shares of $1 par value common stock for cash of $292,500.July
11Issued 2,500 shares of $100 par value preferred stock for cash at $104 per share.
Nov. 28Purchased 1,000 shares of treasury stock for $7,100. Prepare a tabular summary to record
the Blossom Company transactions. (Ifa transaction causes a decrease in Assets, Liabilities or
Stockholders\' Equity, place a negative sign (or parentheses) in front of the amount entered for
the particular Asset, Liability or Equity item that was reduced.) Assets Liabilities Stockholders\'
Equity Paid-in-Capital Retained Earnings Cash +Common Stock+ PIC in Excess of Pa +Pref.
Stock + + Revenue ExpenseDividend Com. Pref June 22 July 11 Nov. 28
Solution
Cash Liabilities Common stock PIC in excess of par Com. Pref. stock PIC in excess of par
Pref. Treasury stock Revenue Expenses Dividend 22-Jun 292500 78000 214500 11-Jul
260000 250000 10000 28-Nov -7100 -7100.
Using the case study below, develop a written report of your market .pdfmanjan6
Using the case study below, develop a written report of your market analysis. Include a visual
diagram of your overall market analysis use of strategic thinking maps (see diagram in the
Module) as a tool to assist with the different facets of the strategic planning process.
The map is to be used as a supplement for your written market analysis. The market analysis
produced will be used in the final submission of your Capstone Project.
Your well-written market analysis should meet the following requirements:
Be 3-4 pages in length, not including the cover, abstract (optional), or reference pages.
Utilize headings to organize the content.
Include the strategic thinking map in addition to/or as a part of the 3-4 pages of content.
Include a minimum of four references with associated in-text citations.
The circumstances in Pocahontas County resonate in many rural communities across the country:
• A depressed local economy
• Substantial barriers to health access
• Difficulty in attracting health professionals.
Portrait of Pocahontas County
Pocahontas County is located in the southeast region of West Virginia. The county has a total of
942 square miles and is the site of the head waters for eight rivers: Cherry River, Cranberry
River, Elk River, Ganley River, Greenbriar River, Tygart Valley River, Williams River, and
Shaver Fork of the Cheat River. Pocahontas County consists of the following towns: Arborale,
Bartow, Buckeye, Cass, Dunmore, Durbin, Greenbank, Hillsboro, Marlington, and Slatyfork.
As of the 2010 Census there are 9,131 people residing in Pocahontas County. The racial makeup
is 98% Caucasian, .78% African American, .43% Hispanic, .14% Asian, and .07% Native
American. The median income for a household within the county is $26,401.
Access to Health Services
Pocahontas County has a shortage of healthcare providers. There is one hospital, Pocahontas
Memorial Hospital, and one nursing home, Pocahontas Center. The ratio for dentists is 8,851 to
1. The ratio for primary care physicians is 8508 to 1 (County Health Roadmaps & Rankings,
n.d.). The county’s physician-to-population ratio is significantly higher than the Unites States
overall ratio.
Pocahontas Memorial Hospital is a 25-bed, level-4 trauma center. A rural health clinic is located
within the hospital. The health clinic offers laboratory services, immunizations, disease
management, and monthly specialty clinics (cardiology, podiatry, and nephrology).
For more information about Pocahontas Memorial Hospital, visit the following website:
http://www.pmhwv.org/
Solution
Health care Limitations
Executive summary
The health care industry which is also known as the health economy or the medical industry is a
broad industry which specializes in the delivery of services regarding treatment of diseases,
conducting diagnostic services and therapies to identify various diseases so at to understand the
kind of treatment to be subjected to such diseases (World Health Organization. (2002). the
industr.
Which of the following is NOT a characteristic of a plasmid used as .pdfmanjan6
Which of the following is NOT a characteristic of a plasmid used as a cloning vector?
A. contains a selection marker.
B. contains an origin of replication.
C. has a site for inserting foreign DNA.
D. integrates into the host chromosome.
E. has lacZ gene at the insertion site
Solution
D. integrates into the host chromosome.
a vector is a DNA molecule that is used as a vehivle for the introduction of foreign genetic
material in the cell.Most commonly used vectors are plasmids,cosnids,viral vectors.Some
features that are common to all vectors are origin of replication,multicloning site and a selectable
marker system.A vector replicates autonomously irrespective of the replication of host DNA.A
vector does not integrate into the host chromosome..
What is the evolutionary significance of the amniotic egg Solut.pdfmanjan6
What is the evolutionary significance of the amniotic egg?
Solution
The fluid in the sac keeps the embryo moist. Birds, reptiles, and mammals have amniotic eggs.
Because amphibian eggs don\'t have an amnion, the eggs would dry out if they were laid on the
land, so amphibians lay their eggs in water. The larvae of most amphibians have gills and look
like fish when they are born..
What is the role of HTTP What types of objects are transmitted in H.pdfmanjan6
What is the role of HTTP? What types of objects are transmitted in HTTP? Is HTML part of the
HTTP specification?
Solution
Hyper Text Transfer Protocol defines a set of rules that 2 entities namely Client and Server need
to follow while communicating with each other. It is a application layer protocol. This protocol
is based on Client and Server. Client is someone who needs something from web while server is
something who needs to listen to what Client wants and then need to send appropriate response.
Role of HTTP :
1. It allows Client/User to send request for any content that is available in web Server.
2. It provides authentication mechanisms like basic access authentication and digest access
authentication .
3. It allows the seamless transmission of Hyper Text from Server to Client and vice versa.
4. It allows persistent connections as well where a connection could be reused for more than one
request.
Objects Transmitted-
1. Request message - It is a command which Client sends to server which determines the content
wants to access.
Format - GET HTTP version
Example- GET /index.html/hello.jpg HTTP/1.1
2. Response Message - The server send a response to client request if the requested content is
available with it.
Format -
a) A status line which includes the status code and reason message (e.g., HTTP/1.1 200 OK,
which indicates that the client\'s request succeeded).
b) Response header fields (e.g., Content-Type: text/html).
c) An optional message body.
Example-
No, HTML is not a part of HTTP Specification..
What is the difference between a hash in perl and a hashtable in Jav.pdfmanjan6
What is the difference between a hash in perl and a hashtable in Java? What are some concrete
examples?
Solution
There are lot of differece between hash in perl and hashtable in java
concrete Examples:
1) Insertion is done using a put method in java. It is done directly in perl
In Java: data.put(\'John Paul\',45)
In Perl; $data{\'John Paul\'} = 45;
2) In Java We have to specify datatypes of key and value before hand while defing the hashtable
variable. It is not necessary in perl..
What are the specific linkages among immune surveillance, clonal sel.pdfmanjan6
What are the specific linkages among immune surveillance, clonal selection, and lymph nodes?
Solution
Immune Surveillance - A hypothesis that the immune system perceives and pulverizes tumor
cells that are continually emerging amid the life of the person. A body component by which early
growths are recognized as being strange and are assaulted and typically pulverised. Immune
Surveillance is a process in which a T cell-intervened handle without which tumor would be
much ordinary.
The immune sytem can distinguish and crush rising cancer cells since it perceives strange
antigens on the cell surface as \'foreign substance\' or outsider. Since outside substances are
typically risky to the body, the immune system is customised to demolish them. This consistent
checking of the body for little tumors is immune surveillance. The immune surveillance of living
body is known to work in the dismissal of tumor cells in people with inherited nonpolyposis
colon growth, likewise called Lynch disorder. Those people acquire a broken DNA confound
repair framework and as an outcome deliver numerous mutant proteins. At the point when such
mutant proteins show up on the surface of tumor cells, they are perceived as foriegn and rejected.
Tumors that do rise are those that have figured out how to sidestep the body\'s immune system.
Lymph nodes are Bean Shaped and encapsulated antigen gathering tissues that channel lymph
and permit lymphocytes to test antigens gained from skin, GI tract and respiratory tract
- deliberately situated all through body, bolstered by reticular system of follicular DCs and
macrophages
- lymphocytes enter from blood crosswise over high endothelial venules and from the
interconnected lymphatic vessels; B cells relocate to the cortex and immune system
microorganisms move to paracortical area; plasma move to medulla and emit counter acting
agent
- DCs with antigen enter from lymphatic vessel; T cells and DCs reach each other the T cell tests
the antigens in setting of the MHC on the DC; enacted T cells leaves lymph hubs and enter the
blood to site of contamination.
Clonal Selection - Clonal selecction is a hypothesis clarifying how the cells of the immune
system deliver vast amounts of the correct counter acting agent at the ideal time, in the sense, at
the point when the proper antigen is experienced. It suggests that there is a previous pool of
lymphocytes i.e B cells comprising of various little subsets. Every subset conveys a one of a kind
arrangement of surface counter acting agent atoms with its own specific restricting qualities. In
the event that a cell experiences and ties the comparing antigen it is `selected\' – empowered to
partition more than once and deliver a substantial clone of indistinguishable cells, all emitting the
counter acting agent. The contribution of aide T cells is basic for actuation of the B cell. A type
of clonal determination is additionally summoned to clarify the improvement of immunological
resistance.
True or False –Paraeducators provide direct or indirect instructio.pdfmanjan6
True or False –
Paraeducators provide direct or indirect instructional and other services to students under the
supervision of a lead paraeducator.
Solution
it is true
Roles And Responsibilities Of Paraeducators
Over the years, the roles and responsibilities of paraeducators have become more complex and
have expanded to include numerous aspects of the educational process for studentswith
disabilities (Drecktrah, 2000; French & Pickett, 1997; Pickett, 1999). In practice, the dutiesof a
paraeducator may include, but are not limited to:
•
providing direct and small group instruction
•
adapting and modifying curriculum
•
monitoring student behavior
•
communicating with parents and families (many believe this should not reflect the role
of paraeducators)
•
performing clerical duties, and
•
providing personal care.
The situation where the few who yell the loudest get heard Is ref.pdfmanjan6
The situation where \"the few who yell the loudest get heard\" Is referred to as the Multiple
Choice special-interest effect. principal-agent problem. moral hazard problem.
Solution
Answer:- the situation where the few who yell the loudest gets heard is referred to as the
Correct Answer:- Special interest effect
Reason:- “the special interest effect,” explains why, over time, the legislative process tends to
generate more expansive government..
Templated Binary Tree implementing function help I need to im.pdfmanjan6
\"Templated Binary Tree\" implementing function help ?
I need to implement header file which i am working on.
Void expandExternal and void preorder part :
1. Header File :
#ifndef BINARYTREE_H
#define BINARYTREE_H
#include
////////////////////////////////////
// Templated Node Interface
///////////////////////////////////
template // base element type
class Node { // a node of the tree
public:
Node() : elt(), par(NULL), left(NULL), right(NULL) { } // constructor
private:
E elt; // element value
Node* par; // parent
Node* left; // left child
Node* right; // right child
template friend class BinaryTree;
template friend class Position;
};
////////////////////////////////////
// Templated Binary Tree Interface
///////////////////////////////////
template // base element type
class BinaryTree
{
public: // public types
//Defines a node position
class Position
{
public:
Position(Node * _v = NULL) : v(_v) { } // constructor
//Returns the element at the position
E& operator*()
{
return v->elt;
}
//Returns a Position object
Position left() const // get left child
{
return Position(v->left);
}
//Returns a Position object
Position right() const // get right child
{
return Position(v->right);
}
//Returns a Position object
Position parent() const // get parent
{
return Position(v->par);
}
//Returns true or false
bool isRoot() const // root of tree?
{
return v->par == NULL;
}
//Returns true or false
bool isExternal() const // an external node?
{
return v->left == NULL && v->right == NULL;
}
//Returns true or false
bool isInternal() const // an external node?
{
return ! isExternal();
}
private:
Node* v;
template friend class BinaryTree;
};//End Position class definition
/* Position List type definition*/
typedef std::list PositionList;
public: //Binary member functions
BinaryTree() : _root(NULL), n(0) { }
~BinaryTree(); // The destructor need to properly deletes all nodes in the tree to prevent
memory leaks.
int size() const; // Returns and integer tof the number of nodes.
bool empty() const; // Returns a true if the tree is empty else false.
Position root() const; // Return the position of the root node.
void addRoot(); // Creates and adds the initial root node to the tree this must be added first.
void expandExternal(const Position& p); //Expands each external node with a left and right
child that are empty.
// What goes here?
PositionList positions() const; // Returns a std:list of the nodes in the tree call preorder()
function.
void preorder(Node* v, PositionList& pl) const; // Traversal algorithm for the tree to populate
the PositionList
// What goes here?
private:
Node * _root; // pointer to the root
int n; // number of nodes
};
#endif
Thank you
Solution
for the main function, try writing the code like this :
struct Node{
Comparable element;
Node *left;
Node *right;
Node(const Comparable & theElement, Node *lt, Node *rt )
: element( theElement ), left( lt ), right( rt ) {}
}; // Node{}
Node *root;
Node * findMin( Node *t ) const;
Node * findMax( Node *.
State if you agree or disagree with the question and comments made b.pdfmanjan6
State if you agree or disagree with the question and comments made below and why?
Does Maryland’s new social media campaign rule go far enough to validate who is posting the
political information on social media? Maryland has begun a great new way of identifying
political advertisers support of particular politicians. But, this may not do everything that it needs
to do in order to validate who is behind the postings or what is the motivation of the poster. If a
political poster wished to disguise themselves and pretend to support a particular candidate, he or
she could easily tag the advertisement with the legally required statement but still not be
affiliated with the campaign they are supporting. This law would need to be broadened to include
campaign-assuming responsibility for monitoring or approving any post made in their name. In
order to achieve this goal, campaigns would need huge numbers of paid and volunteer team
members just to monitor social media. Otherwise, social media, such as Facebook and Twitter,
would need to have to take more responsibility for the IP addresses they allow to advertise on
their platforms. Since this is a new legal development, it will need to be fine-tuned in order to
protect the public from scammers.
Solution
With the emergence of social media networking being used to advertising in every field, the
same has been done by the political advertisers. With this grew the forgery in the posts that were
made in the name of political parties. So Maryland levied this law in which the political
advertisers will have to identify their political campaign material before posting it on social
media and can post it following set rules and guidelines.
In the above matter it is mentioned that these rules will not eradicate the issue of false
advertising totally as the political poster can be disguised and pretend to support a particular
candidate. Tagging the advertisement with a legally required statement can be done even though
they may not be affiliated with the campaign they are showing support for. To overcome this
forgery ways will have to be found out to monitor and approve any post made in the name of a
candidate or party by the party or candidates. For this special team members will have to be hired
to keep a monitoring eye on the posts on social media. Also the social media can help by keeping
a track of all the IP addresses they allow for the advertisements done ussing their platforms.
These steps are essential to be taken in the political advertising campaigns as they will help
erasing the false advertising in the names of political parties and make social media a trusted and
genuine platform for such advertising..
A number of benefits that one might expect to see from using a datab.pdfmanjan6
A number of benefits that one might expect to see from using a database such as MySQL. List
four of these benefits and in your own words describe the benefit.
Solution
Some of the benefits are:
Heavily Supported: It supports software on a variety of platforms and operating systems
including Windows, Linux, Novell NetWare, UNIX and more.
Secure: It help solid data security layers to safeguard sensitive data from outside access. All
passwords used to entry the MySQL database are encrypted.
Fast: When compared to other database software MySQL is much agile in terms of performance,
and users still have approach to all the required features they would through other database
platforms.
Data Storage is Scalable: MySQL can handle a overall file size limit of about 4GB, however, this
can be enlarged to meet our needs – by as much as 8TB of data.
Manages Memory: The database software has been shown to guide memory vastly well and
prevents memory leaks which we might experience on a server where it’s not deployed..
QUESTION If you look at the code, youll see that we keep two list.pdfmanjan6
QUESTION: If you look at the code, you\'ll see that we keep two lists, one to print the text in
forward order, and one to print the text in reverse order. The forward one is using our empty
add() function, so nothing gets put into it. You\'ll fix that, as well as modifiying insert() and
erase(). The reverse on works by inserting always at the head of the list, like a Stack.Functions
insert(), erase(), and add() must be modified so that if the last node of the list changes, List::last
must change, as well. YOU JUST HAVE TO COMPLETE THE LIST.CPP FILE SO THAT IT
PRINTS THE OUTPUT IN THE FORWARD ORDER.FINISH THE CODE ONLY IN
LIST.CPP FILE AND OTHER FILES ARE JUST FOR REFERENCE. MORE
INFORMATION AND HINTS ARE GIVEN IN THE COMMENTS IN LIST.CPP FILE.
HINT: AFTER the existing code runs, there\'s an easy way to know if you just changed the last
node in the list; if you did, it\'s time to update the \"last\" pointer. And remember that \'add\'-ing
the first item is a special case. We could make a Linked List behave a lot like a Queue if it were
really efficient to add a node at the end of the list, that is, without having to chase links from the
head to the tail. So we will add another pointer to our List class that will always point at the last
item in the list. Read the existing code carefully and understand how it works. The \"add\"
function is now empty. If you run the file you should get an output that starts out like this:
?CURRENT LIST.CPP:
CURRENT OUTPUT:
MAIN.CPP FILE:
LIST.H FILE: include list include
Solution
PROGRAM CODE:
/*
* List.cpp
*
* Created on: 29-Nov-2016
* Author: kasturi
*/
#include \"List.h\"
#include
#include
#include
using namespace std;
void List::insert(ElemetType item, int position)
{
Node * predptr = first;
for(int i=1; i< position && predptr && predptr->next; i++)
{
predptr = predptr->next;
}
Node * newptr = new Node;
newptr->payload = item;
if(!predptr)
{
newptr->next = 0;
first = newptr;
}
else if(position == 0)
{
newptr->next = first;
first = newptr;
}
else
{
newptr->next = predptr->next;
predptr->next = newptr;
}
}
void List::erase(int position)
{
Node * predptr = first;
for(int i=1; inext; i++)
{
predptr = predptr->next;
}
if(!predptr)
{
}
else if(position == 1)
{
first = predptr->next;
delete predptr;
}
else
{
Node *ptr = predptr->next;
predptr->next = ptr->next;
delete ptr;
}
}
void List::display(ostream& ostr)
{
Node * ptr = last; //changed the display function to print the first
while(ptr)
{
ostr<payload<next;
}
}
List::List()
{
first = 0;
last = 0;
}
List::~List()
{
while(first)
{
Node *nxt = first->next;
delete first;
first = nxt;
}
}
void List::add(ElemetType item)
{
//added code to add values into the last node
Node * predptr = last;
Node *newptr = new Node;
newptr->payload= item;
while( predptr && predptr->next)
{
predptr = predptr->next;
}
if(!predptr)
{
newptr->next = 0;
last = newptr;
}
else
{
newptr->next = predptr->next;
predptr->next = newptr;
}
}
OUTPUT:
Forward:
The
quick
brown
fox
jumped
over
the
back.
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdfmanjan6
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if its pressure is 568 Torr
and its temperature is 25 degrees Celsius? 4.2L O120.8 8.4 L 12.7L
Solution
Mole of carbon dioxide= mass/molar mass
Molar mass of co2 =44g/mol
Mole = 17/44=0.386 mole
We use pv=nrt
Pressure=568 torr. = 0.747 atm
R = 0.08206atm.L/mol.k
0.747*V= 0.386*0.07206*298
Volume=12.7 L.
Match the enzyme activity in DNA synthesis with its function. DNA po.pdfmanjan6
Match the enzyme activity in DNA synthesis with its function. DNA pol III (_) fragments
Helicase (_) Primase (_) using template strand DNA pol I (_) double helix DNA ligase (_) adds
nucleotides Topoisomerase (_) primer A. anneals DNA B. relieves overwinding C. adds
nucleotides D. unwinds parental E. removes RNA primer, F. adds a short RNA 10
Proofreading and repair of the DNA double helix does NOT involves a. detecting a mis-match
in base pairs. b. removing the mis-match with a nuclease. c. annealing the Okazaki fragments
together with DNA ligase. d. repairing the mis-match with polymerase. e. annealing the edited
DNA with the rest of the molecule with ligase.
Solution
4. DNA Pol III- (C)- DNA polymerase III is the primary enzyme involved in DNA replication
which adds nucleotides to the 3\' end of the forming DNA strand during replication.
5. Helicase- (D)- Helicases are enzymes that separates double-stranded DNA into single strands
allowing each strand to be copied.
6. Primase- (F)- Primase functions by synthesizing short RNA sequences that are complementary
to a single-stranded DNA.
7. DNA Pol I- (E)- DNA polymerase-I fills in the necessary nucleotides between the Okazaki
fragments in a 5\'3\' direction.
8. DNA ligase- (A)- DNA ligases are essential for the joining of DNA fragments during
replication.
9. Topoisomerase- (B)-Topoisomerases are enzymes that participate in the overwinding or
underwinding of DNA.
10. Okazaki fragments are only formed during DNA replication and not observed during DNA
proof reading and repair. Therefore answer is (C).
Introduction to Engineering ExperimentationSurface temperature con.pdfmanjan6
Introduction to Engineering Experimentation
Surface temperature conduction error of a thermal probe...(more than one answer may be correct)
a. is systematic
b. is random
c. will produce a lower reading (assuming the surface is hotter than the surroundings)
d. will produce a higher reading
Solution
answer is C and D.
Systematic errors are situation dependent.
sometimes poor probe design or bad installation can easily give a system significant temperature
reading errors..
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Please help with this. program must be written in C# .. All of the g.pdf
1. Please help with this. program must be written in C# .. All of the game logic must be written in a
seperate class using using an array that is passed in through a prperty that represents the game
board. The class needs to have methods to determine of someone won, or if there was a tie,
make sure all business logic is in a seperate class anot behind the UI..
***** These are the complete in instructions for the game assignment design
Create a Tic-Tac-Toe game that can be played by two players. The form will consist of a Tic-
Tac-Toe board in which the users’ click on to choose their space. As the game is being played
the Game Status section will tell whose turn it is. When someone wins or there is a tie, a message
will be displayed in the Game status section telling the users the status. When someone wins the
game the winning move needs to be indicated. There also needs to be a section that keeps track
of the number of wins for each player, and the number of ties. When the game is finished the
user may click the “Start Game” button to start a new game.
This program will consist of the main form and at least one class that will define the rules of the
game. This class will have an array that is passed in through a property that represents the game
board. The class will then have methods within it that determines if someone won, if there is a
tie, or if neither has occurred yet. Make sure all business logic is in a separate class and not
behind the UI.
EXTRA CREDIT (10 Points)
Create a computer player that can be played against. The computer player will need to be smart
enough to make a winning move or to block a winning move.
Solution
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Tic_Tac_Toe
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
2. Logic logicObj = new Logic();
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
int turn=1;
int click1=0,click2=0,click3=0,click4=0,click5=0,click6=0,click7=0,click8=0,click9=0;
int player1=0,player2=0;
void Button1Click(object sender, EventArgs e)
{
if(click1==0)
{
if(turn%2!=0)
{
button1.Text="X";
click1++;
}
else
{
button1.Text="O";
click1++;
}
turn++;
}
else
{
button1.Text=button1.Text;
}