ArrayListOfObjects
Assignment 4:
100 points
due Thurs, Feb 23rd.
Adapt your ArrayOfPokemon code from assignment 2 to use the new Pokemon objects.
When adding a Pokemon, instead of making the user enter all the information, make a menu for
them to pick from the nine (or more) implemented species: (Bulbasaur, Ivysaur, Venusaur,
Charmander, Charmaleon, Charizard, Squirtle, Wartortle, Blastoise).The only thing the user must
choose is the species of Pokemon and if it gets a name.
If they want a name, then the program should ask them to enter one.
Then call the constructor for the chosen Pokemon. For example: Pokemon p = new Bulbasaur();
or Pokemon p = new Squirtle(sName);
Change the Array from assignment 2 to a Java API ArrayList.
For examples on using an ArrayList, see the uploaded sample code ArrayListDemo.java and
slide 40 of ICS211_Lecture09_ListsAndContainers.pdf on Laulima -> Resources -> Week 5.
Also see the Java API website for ArrayList for available methods.
The allowed number of stored Pokemon should still be limited to 6. Don\'t let the ArrayList keep
growing though it can!
Assignment 2 code is here,Please help me change it to match Assignment 4\'s requirement.
This is the Pokemon.java code.import java.util.*; //scannerpublic class PokeArray{static final int
SIZE = 6;public static void main(String[] args){Scanner userIn = new
Scanner(System.in);String inString = new String(\"\");boolean endLoop = false;Pokemon[]
arrPoke = new Pokemon[SIZE];int nextIndex = 0; //points to index for next insert//loop until
stopping condition is givenwhile(endLoop != true){//menu textSystem.out.println(\"Please enter
the number of your choice:\");System.out.println(\"1. Add a Pokemon\");System.out.println(\"2.
Print all Pokemon\");System.out.println(\"0. Exit the program\");System.out.print(\"What
would you like to do? \");//read in from user as a String -- much less errors can happen!inString
= userIn.nextLine();//take off any spaces on the stringinString = inString.trim();//just switch on
the String no need to convert to intswitch(inString){case \"0\": endLoop =
true;System.out.println(\"Good bye!\");break;case \"1\": //do stuff to make a new
PokemonarrPoke[nextIndex] = PokeArray.makePokemon();nextIndex = (nextIndex + 1)%
SIZE; //makes value run from 0-5 alwaysbreak;case \"2\": //print out all the
PokemonPokeArray.printArray(arrPoke);break;default: //not a valid menu
entrySystem.out.println(\"\ ****Invalid menu choice.****\ Please enter a 0, 1, or 2\
\");break;}}}//close main method/** makePokemon asks user for data for a new Pokemon
object and instantiates it** @return a Pokemon to insert into the array*/public static Pokemon
makePokemon(){Scanner userIn = new Scanner(System.in);Pokemon newPoke;//Data for new
Pokemon constructorString inName = new String(\"\");String inNick = new String(\"\");String
inNum = new String(\"\");//have to convert to an intString inType1 = new String(\"\");String
inType2 = new String(\"\");int iNum = 0;boolean dataGood = fals.
import java.util.ArrayList;
import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer\'s inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer\'s inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
* @param pokedexNumber the Pokedex Number for the species
* @param speciesName the name of the species
* @param candies the number of candies the player has obtained by catching
* or transferring Pokemon of this species
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player\'s inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
// TODO
caughtPokemon.add(pokemon);
this.candies++;
}
/**
* Helper function to load Pokemon from a save file into the player\'s inventory for this
* Pokemon Species
*
* @param pokemon the pokemon to add to this species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player\'s inventory for this species.
*
* @param cp the combatPower of the Pokemon to find
* @throws PokedexException [Config.POKEMON_NOT_FOUND] if there is no Pokemon
with the
* given combatPower in the player\'s inventory.
* @return the first Pokemon with the provided combatPower
*/
public Pokemon findPokemon(int cp) throws PokedexException {
// TODO
for(int i=0;i 0){
return true;
}
return false;
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player\'s inventory.
*
* @return a String of the form
* ...
*/
public String caughtPokemonToString() {
// TODO
return pokedexNumber+\" Name: \"+speciesName+\" Candies\"+candies;
}
/**
* Prepare a String representing this entire PokemonSpecies. This is used to
* save the PokemonSpecies (one part of the Pokedex) to a file to
* save the player\'s game.
*
* @return a String of the form
* [, ,.
can someone fix the errors in this code- the name needs to be Fraction.pdfvinaythemodel
can someone fix the errors in this code? the name needs to be FractionDemo.java
//author: Jazmine Tapia
//date: 20 February 2023
//file: FractionDemo.java
/*
Lab 13 will also be using demonstation the
the multiplication of two factors.
*/
//import statements for Scanner class
import java.util.Scanner;
// Define a public class called Fraction
public class FractionDemo
{
// Define private instance variables for the numerator and denominator
private int numerator;
private int denominator;
// Define a constructor for the Fraction class that takes a numerator and denominator as
arguments
public FractionDemo(int numerator, int denominator)
{
// Set the denominator using the setDenominator() method defined below
setDenominator(denominator);
// Set the numerator
this.numerator = numerator;
// Reduce the fraction
reduce();
// Adjust the signs of the numerator and denominator if necessary
adjustSigns();
}
// Define a getter method for the numerator
public int getNumerator()
{
return numerator;
}
// Define a setter method for the numerator
public void setNumerator(int numerator)
{
this.numerator = numerator;
}
// Define a getter method for the denominator
public int getDenominator()
{
return denominator;
}
// Define a setter method for the denominator
public void setDenominator(int denominator)
{
// Set the denominator using the setDenominator() method defined below
setDenominator(denominator);
// Reduce the fraction
reduce();
// Adjust the signs of the numerator and denominator if necessary
adjustSigns();
}
// Define a private method to set the denominator
private void setDenominator(int denominator)
{
// If the denominator is zero, throw an exception
if (denominator == 0)
{
throw new IllegalArgumentException("Denominator cannot be zero");
}
// Set the denominator
this.denominator = denominator;
}
// Define a private method to calculate the greatest common divisor of two integers
private int gcd(int a, int b)
{
if (b == 0)
{
return a;
} else {
return gcd(b, a % b);
}
}
// Define a public method to reduce the fraction
public void reduce()
{
// Calculate the greatest common divisor of the numerator and denominator
int gcd = gcd(numerator, denominator);
// Divide both the numerator and denominator by the greatest common divisor to reduce the
fraction
numerator /= gcd;
denominator /= gcd;
}
// Define a private method to adjust the signs of the numerator and denominator if necessary
private void adjustSigns()
{
// If the denominator is negative, multiply both the numerator and denominator by -1 to adjust
the signs
if (denominator < 0)
{
numerator *= -1;
denominator *= -1;
}
}
// Define a public method to add two fractions
public FractionDemo add(FractionDemo other)
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
// Get the numerator and denominator for the first fraction
System.out.print("Enter the numerator of the first fraction: ");
int num1 = input.nextInt();
System.out.print("Enter the denominator of the first fraction.
(10 pts) Write a function called isInBetween that takes 3 ints, say .pdfanjandavid
(10 pts) Write a function called isInBetween that takes 3 ints, say n, low and high, and returns a
boolean; the function returns true if the first parameter (n) is between the second and third
parameters (low and high, INCLUSIVE), and false otherwise. Can safely assume that low is
lower than high.
Solution
/* I have written this code in java as you have not mentioned
any specific language in the question,Please do ask in case of any doubt,Thanks */
import java.util.*;
public class HelloWorld{
public static void main(String []args){
Scanner input=new Scanner(System.in); //object for taking input
System.out.println(\"Enter n: \");
int n=input.nextInt(); //first parameter
System.out.println(\"Enter low: \");
int low=input.nextInt(); //second parameter
System.out.println(\"Enter hih: \");
int high=input.nextInt(); //third parameter
//calling isInBetween(n,low,high) and printing the returned value
System.out.println(\"Result: \"+isInBetween(n,low,high));
}
/* method isInBetween(n,low,high) */
public static boolean isInBetween(int n,int low,int high){
/* if 1 parameter is in between low and high return true */
if(low<=n && n<=high)
return true;
else /* else return false */
return false;
}
}
/*******OUTPUT********
sh-4.3$ javac HelloWorld.java
sh-4.3$ java -Xmx128M -Xms16M HelloWorld
Enter n:
2
Enter low:
1
Enter hih:
3
Result: true
**********OUTPUT********/.
PROGRAM 2 – Fraction Class Problem For this programming as.pdfezonesolutions
PROGRAM 2 – Fraction Class
Problem For this programming assignment, you are to implement the Fraction class design
given below (and discussed in class). You are also to develop an appropriate test driver that
thoroughly tests the class.
Fraction Class Design Implement the following class design. Make sure to use implement the
methods to have the same names as given below, with the same number and types of parameters.
public class Fraction {
private int numer;
private int denom;
// alternate constructor
public Fraction(int numer, int denom)
throws InvalidDenominatorException {
}
// copy constructor
public Fraction(Fraction otherFrac) {
}
// getters
public int getNumer() {
}
public int getDenom() {
}
// standard methods
public String toString() {
}
public boolean equals(Fraction rFrac) {
}
// fraction operators
public Fraction add(Fraction rFrac) {
}
public Fraction sub(Fraction rFrac) {
}
public Fraction mult(Fraction rFrac) {
}
public Fraction div(Fraction rFrac) {
}
public boolean isSimplestForm() {
}
public Fraction reduce() {
}
public boolean properFrac() {
}
public Fraction abs() {
}
public boolean lessThan(Fraction rFrac) {
}
public boolean greaterThan(Fraction rFrac) {
}
public double convertToDecimal() {
}
public Fraction invert() {
}
}
Note that objects of type Fraction are immutable. Also, the alternate constructor throws an
InvalidDenominatorException if passed a denominator value of 0. This exception type is not
predefined in Java, so you must define it as follow as another class in your Java project files:
public class InvalidDenominatorException extends RuntimeException { } // nothing to
implement
This creates an exception of type RuntimeException. RuntimeExceptions do not need to be
caught when thrown. However, your test driver should have the code for catching this exception
where appropriate.
For example, if your test driver excutes the following,
Fraction frac1 = new Fraction(1,2);
then there is no need to catch the possible exception, since it is clear that the denominator is not
0. However, if the value are input by the user, then there is a chance that a denominator vaue of 0
could be entered, and therefore the code for catching the possible exception is needed,
int numer, denom;
Fraction frac1;
Scanner input = new Scanner(System.in);
Boolean valid_input = false;
while (!valid_input) try {
System.out.print(“Enter numerator denominator: “);
numer = input.nextInt();
denom = input.nextInt();
frac1 = new Fraction(numer,denom);
valid_input = true;
}
catch (InvalidDenominatorException e) {
System.out.println(“Denominator of Zero found – Please reenter”);
}
catch (InputMismatchException e) {
System.out.println(“Non-digit character found – Please reenter”);
} etc.
Considerations
Makes sure the equals method returns true for any two fractions that are arithmetically equal.
Make sure that the equals, lessThan and greaterThan methods do not alter the values of the
fractions being compared. You may consider the use of private methods .
import java.util.ArrayList;
//import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer\'s inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer\'s inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player\'s inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
this.addNewPokemonCandies();
}
/**
* Helper function to load Pokemon from a save file into the player\'s inventory for this
* Pokemon Species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player\'s inventory for this species.
*
*/
public Pokemon findPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
Pokemon mon = caughtPokemon.get(i);
if(mon.getCombatPower() == cp){
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Transfer a Pokemon with the provided combatPower from the player\'s inventory
* to the Professor. This removes the Pokemon from the player\'s inventory and
* also increases the number of candies the player has associated with this
* PokemonSpecies.
*/
public Pokemon transferPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
if(caughtPokemon.get(i).getCombatPower() == cp){
Pokemon mon = caughtPokemon.remove(i);
this.addTransferCandies();
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Check if the player has any Pokemon of this species
*/
public boolean isEmpty() {
return caughtPokemon.isEmpty();
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player\'s inventory.
*
*/
public String caughtPokemonToString() {
String pokemonStr = \"\";
.
Main issues with the following code-Im not sure if its reading the fil.pdfaonesalem
Main issues with the following code:Im not sure if its reading the file correctly because its
adding all terms together. In other words the the first line of terms is adding the second line of
terms but thats not my intention. Each line of term should have their own polynomial expression
as shown below
Basic specifications :
The code should add the polynomial numbers using a linked list. Java . Keep in mind the
polynomials will be gotten from a file.
Things to keep in mind the list should be in decending order and traverse the list after
all coefficient/exponent pair Term nodes from one input line have been
inserted.
Here are the specifications
//The Polynomial class would likely have a single private data member (reference to
class Term) called head.
//The Term class would likely have three private data
members (coefficient and exponent of type int) and next of type reference to
Term.
//The latter class would also have the following public methods:
constructor(s), gets and sets for each data member, and perhaps a formatting
method with the special output requirements.
An example of input is 7 1 2 4 6 2 -3 2 -1 -1 3
Negative negative
pair signals the termination
***NO doubly linked list , it should be a single linked list **
Input file contains the following :
7 1 2 4 6 2 -3 2 -1 -1 3 ----> 2x^4 - 3x^2 +6x^2 + 7x
5 1 2 3 6 0 -3 2 -1 -1 3 ----> 2*X^3 + (-3)*X^2 + 5*X + 6 // thats the ouput for one line of the
the file , each line of the file should have one polynomial output
Code
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Polynomial {
private Term head;
// Constructor for creating an empty polynomial object
public Polynomial() {
head = null;
}
// Method for adding a term to the polynomial, this is inside the polynomial term
public void addTerm(int coefficient, int exponent) {
// Create a new term object
Term newTerm = new Term(coefficient, exponent);
// If the polynomial is empty, set the new term as the head
if (head == null) {
head = newTerm;
} else {
// Traverse the polynomial until we find the correct position for the new term
Term current = head;
Term previous = null;
while (current != null && current.getExponent() > exponent) {
previous = current;
current = current.getNext();
}
// If a term with the same exponent already exists, add the coefficients
if (current != null && current.getExponent() == exponent) {
current.setCoefficient(current.getCoefficient() + coefficient);
} else {
// Otherwise, insert the new term into the polynomial
if (previous == null) {
head = newTerm;
} else {
previous.setNext(newTerm);
}
newTerm.setNext(current);
}
}
// Method for formatting the polynomial as a string
public String toString() {
StringBuilder sb = new StringBuilder();
if (head != null) {
sb.append(head.toString());
Term current = head.getNext();
while (current != null) {
if (current.getCoefficient() > 0) {
sb.append(" + ");
} else {
sb.append(" - ");
}
sb.append(current.toString());
current = cur.
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(.
import java.util.ArrayList;
import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer\'s inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer\'s inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
* @param pokedexNumber the Pokedex Number for the species
* @param speciesName the name of the species
* @param candies the number of candies the player has obtained by catching
* or transferring Pokemon of this species
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player\'s inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
// TODO
caughtPokemon.add(pokemon);
this.candies++;
}
/**
* Helper function to load Pokemon from a save file into the player\'s inventory for this
* Pokemon Species
*
* @param pokemon the pokemon to add to this species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player\'s inventory for this species.
*
* @param cp the combatPower of the Pokemon to find
* @throws PokedexException [Config.POKEMON_NOT_FOUND] if there is no Pokemon
with the
* given combatPower in the player\'s inventory.
* @return the first Pokemon with the provided combatPower
*/
public Pokemon findPokemon(int cp) throws PokedexException {
// TODO
for(int i=0;i 0){
return true;
}
return false;
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player\'s inventory.
*
* @return a String of the form
* ...
*/
public String caughtPokemonToString() {
// TODO
return pokedexNumber+\" Name: \"+speciesName+\" Candies\"+candies;
}
/**
* Prepare a String representing this entire PokemonSpecies. This is used to
* save the PokemonSpecies (one part of the Pokedex) to a file to
* save the player\'s game.
*
* @return a String of the form
* [, ,.
can someone fix the errors in this code- the name needs to be Fraction.pdfvinaythemodel
can someone fix the errors in this code? the name needs to be FractionDemo.java
//author: Jazmine Tapia
//date: 20 February 2023
//file: FractionDemo.java
/*
Lab 13 will also be using demonstation the
the multiplication of two factors.
*/
//import statements for Scanner class
import java.util.Scanner;
// Define a public class called Fraction
public class FractionDemo
{
// Define private instance variables for the numerator and denominator
private int numerator;
private int denominator;
// Define a constructor for the Fraction class that takes a numerator and denominator as
arguments
public FractionDemo(int numerator, int denominator)
{
// Set the denominator using the setDenominator() method defined below
setDenominator(denominator);
// Set the numerator
this.numerator = numerator;
// Reduce the fraction
reduce();
// Adjust the signs of the numerator and denominator if necessary
adjustSigns();
}
// Define a getter method for the numerator
public int getNumerator()
{
return numerator;
}
// Define a setter method for the numerator
public void setNumerator(int numerator)
{
this.numerator = numerator;
}
// Define a getter method for the denominator
public int getDenominator()
{
return denominator;
}
// Define a setter method for the denominator
public void setDenominator(int denominator)
{
// Set the denominator using the setDenominator() method defined below
setDenominator(denominator);
// Reduce the fraction
reduce();
// Adjust the signs of the numerator and denominator if necessary
adjustSigns();
}
// Define a private method to set the denominator
private void setDenominator(int denominator)
{
// If the denominator is zero, throw an exception
if (denominator == 0)
{
throw new IllegalArgumentException("Denominator cannot be zero");
}
// Set the denominator
this.denominator = denominator;
}
// Define a private method to calculate the greatest common divisor of two integers
private int gcd(int a, int b)
{
if (b == 0)
{
return a;
} else {
return gcd(b, a % b);
}
}
// Define a public method to reduce the fraction
public void reduce()
{
// Calculate the greatest common divisor of the numerator and denominator
int gcd = gcd(numerator, denominator);
// Divide both the numerator and denominator by the greatest common divisor to reduce the
fraction
numerator /= gcd;
denominator /= gcd;
}
// Define a private method to adjust the signs of the numerator and denominator if necessary
private void adjustSigns()
{
// If the denominator is negative, multiply both the numerator and denominator by -1 to adjust
the signs
if (denominator < 0)
{
numerator *= -1;
denominator *= -1;
}
}
// Define a public method to add two fractions
public FractionDemo add(FractionDemo other)
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
// Get the numerator and denominator for the first fraction
System.out.print("Enter the numerator of the first fraction: ");
int num1 = input.nextInt();
System.out.print("Enter the denominator of the first fraction.
(10 pts) Write a function called isInBetween that takes 3 ints, say .pdfanjandavid
(10 pts) Write a function called isInBetween that takes 3 ints, say n, low and high, and returns a
boolean; the function returns true if the first parameter (n) is between the second and third
parameters (low and high, INCLUSIVE), and false otherwise. Can safely assume that low is
lower than high.
Solution
/* I have written this code in java as you have not mentioned
any specific language in the question,Please do ask in case of any doubt,Thanks */
import java.util.*;
public class HelloWorld{
public static void main(String []args){
Scanner input=new Scanner(System.in); //object for taking input
System.out.println(\"Enter n: \");
int n=input.nextInt(); //first parameter
System.out.println(\"Enter low: \");
int low=input.nextInt(); //second parameter
System.out.println(\"Enter hih: \");
int high=input.nextInt(); //third parameter
//calling isInBetween(n,low,high) and printing the returned value
System.out.println(\"Result: \"+isInBetween(n,low,high));
}
/* method isInBetween(n,low,high) */
public static boolean isInBetween(int n,int low,int high){
/* if 1 parameter is in between low and high return true */
if(low<=n && n<=high)
return true;
else /* else return false */
return false;
}
}
/*******OUTPUT********
sh-4.3$ javac HelloWorld.java
sh-4.3$ java -Xmx128M -Xms16M HelloWorld
Enter n:
2
Enter low:
1
Enter hih:
3
Result: true
**********OUTPUT********/.
PROGRAM 2 – Fraction Class Problem For this programming as.pdfezonesolutions
PROGRAM 2 – Fraction Class
Problem For this programming assignment, you are to implement the Fraction class design
given below (and discussed in class). You are also to develop an appropriate test driver that
thoroughly tests the class.
Fraction Class Design Implement the following class design. Make sure to use implement the
methods to have the same names as given below, with the same number and types of parameters.
public class Fraction {
private int numer;
private int denom;
// alternate constructor
public Fraction(int numer, int denom)
throws InvalidDenominatorException {
}
// copy constructor
public Fraction(Fraction otherFrac) {
}
// getters
public int getNumer() {
}
public int getDenom() {
}
// standard methods
public String toString() {
}
public boolean equals(Fraction rFrac) {
}
// fraction operators
public Fraction add(Fraction rFrac) {
}
public Fraction sub(Fraction rFrac) {
}
public Fraction mult(Fraction rFrac) {
}
public Fraction div(Fraction rFrac) {
}
public boolean isSimplestForm() {
}
public Fraction reduce() {
}
public boolean properFrac() {
}
public Fraction abs() {
}
public boolean lessThan(Fraction rFrac) {
}
public boolean greaterThan(Fraction rFrac) {
}
public double convertToDecimal() {
}
public Fraction invert() {
}
}
Note that objects of type Fraction are immutable. Also, the alternate constructor throws an
InvalidDenominatorException if passed a denominator value of 0. This exception type is not
predefined in Java, so you must define it as follow as another class in your Java project files:
public class InvalidDenominatorException extends RuntimeException { } // nothing to
implement
This creates an exception of type RuntimeException. RuntimeExceptions do not need to be
caught when thrown. However, your test driver should have the code for catching this exception
where appropriate.
For example, if your test driver excutes the following,
Fraction frac1 = new Fraction(1,2);
then there is no need to catch the possible exception, since it is clear that the denominator is not
0. However, if the value are input by the user, then there is a chance that a denominator vaue of 0
could be entered, and therefore the code for catching the possible exception is needed,
int numer, denom;
Fraction frac1;
Scanner input = new Scanner(System.in);
Boolean valid_input = false;
while (!valid_input) try {
System.out.print(“Enter numerator denominator: “);
numer = input.nextInt();
denom = input.nextInt();
frac1 = new Fraction(numer,denom);
valid_input = true;
}
catch (InvalidDenominatorException e) {
System.out.println(“Denominator of Zero found – Please reenter”);
}
catch (InputMismatchException e) {
System.out.println(“Non-digit character found – Please reenter”);
} etc.
Considerations
Makes sure the equals method returns true for any two fractions that are arithmetically equal.
Make sure that the equals, lessThan and greaterThan methods do not alter the values of the
fractions being compared. You may consider the use of private methods .
import java.util.ArrayList;
//import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer\'s inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer\'s inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player\'s inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
this.addNewPokemonCandies();
}
/**
* Helper function to load Pokemon from a save file into the player\'s inventory for this
* Pokemon Species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player\'s inventory for this species.
*
*/
public Pokemon findPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
Pokemon mon = caughtPokemon.get(i);
if(mon.getCombatPower() == cp){
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Transfer a Pokemon with the provided combatPower from the player\'s inventory
* to the Professor. This removes the Pokemon from the player\'s inventory and
* also increases the number of candies the player has associated with this
* PokemonSpecies.
*/
public Pokemon transferPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
if(caughtPokemon.get(i).getCombatPower() == cp){
Pokemon mon = caughtPokemon.remove(i);
this.addTransferCandies();
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Check if the player has any Pokemon of this species
*/
public boolean isEmpty() {
return caughtPokemon.isEmpty();
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player\'s inventory.
*
*/
public String caughtPokemonToString() {
String pokemonStr = \"\";
.
Main issues with the following code-Im not sure if its reading the fil.pdfaonesalem
Main issues with the following code:Im not sure if its reading the file correctly because its
adding all terms together. In other words the the first line of terms is adding the second line of
terms but thats not my intention. Each line of term should have their own polynomial expression
as shown below
Basic specifications :
The code should add the polynomial numbers using a linked list. Java . Keep in mind the
polynomials will be gotten from a file.
Things to keep in mind the list should be in decending order and traverse the list after
all coefficient/exponent pair Term nodes from one input line have been
inserted.
Here are the specifications
//The Polynomial class would likely have a single private data member (reference to
class Term) called head.
//The Term class would likely have three private data
members (coefficient and exponent of type int) and next of type reference to
Term.
//The latter class would also have the following public methods:
constructor(s), gets and sets for each data member, and perhaps a formatting
method with the special output requirements.
An example of input is 7 1 2 4 6 2 -3 2 -1 -1 3
Negative negative
pair signals the termination
***NO doubly linked list , it should be a single linked list **
Input file contains the following :
7 1 2 4 6 2 -3 2 -1 -1 3 ----> 2x^4 - 3x^2 +6x^2 + 7x
5 1 2 3 6 0 -3 2 -1 -1 3 ----> 2*X^3 + (-3)*X^2 + 5*X + 6 // thats the ouput for one line of the
the file , each line of the file should have one polynomial output
Code
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Polynomial {
private Term head;
// Constructor for creating an empty polynomial object
public Polynomial() {
head = null;
}
// Method for adding a term to the polynomial, this is inside the polynomial term
public void addTerm(int coefficient, int exponent) {
// Create a new term object
Term newTerm = new Term(coefficient, exponent);
// If the polynomial is empty, set the new term as the head
if (head == null) {
head = newTerm;
} else {
// Traverse the polynomial until we find the correct position for the new term
Term current = head;
Term previous = null;
while (current != null && current.getExponent() > exponent) {
previous = current;
current = current.getNext();
}
// If a term with the same exponent already exists, add the coefficients
if (current != null && current.getExponent() == exponent) {
current.setCoefficient(current.getCoefficient() + coefficient);
} else {
// Otherwise, insert the new term into the polynomial
if (previous == null) {
head = newTerm;
} else {
previous.setNext(newTerm);
}
newTerm.setNext(current);
}
}
// Method for formatting the polynomial as a string
public String toString() {
StringBuilder sb = new StringBuilder();
if (head != null) {
sb.append(head.toString());
Term current = head.getNext();
while (current != null) {
if (current.getCoefficient() > 0) {
sb.append(" + ");
} else {
sb.append(" - ");
}
sb.append(current.toString());
current = cur.
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(.
question.(player, entity ,field and base.java codes are given)Stop.pdfshahidqamar17
question.(player, entity ,field and base.java codes are given)
Stopping Player
All players need to stay within the eld boundaries. This rst class you write will lay some of the
foundation for the logic needed in all your players. Create a class called Stopping that extends
the Player class. A Stopping player will initially move in a random direction and stops moving
when it reaches the border of the playing eld (without leaving the playing eld). The direction that
a player moves in is determined by its speed in each direction: speedX and speedY. You will add
this logic to manipulate the speed attributes for stopping in its play() method. Take care to notice
that the images of the players have some size to them. Your player should not “visually” leave
the eld. All parts of the image should be on or inside the eld boundaries.
player class;
public abstract class Player extends Entity{
/** this player\'s team name */
protected String team;
/** this player\'s name */
protected String name;
/** this player\'s number */
protected int number;
/** gets this player\'s team name
*
* @return the team name that this player is on
*/
public final String getTeam(){ return this.team; }
/** gets this player\'s name
*
* @return the name of this player
*/
public final String getName(){ return this.name; }
/** gets this player\'s number
*
* @return the number of this player
*/
public final int getNumber(){ return this.number; }
/** creates a player with specified symbol at specified position
*
* @param f is the field the player will be playing on
* @param side is the side of the field the player will play on
* @param name is this name of the player
* @param number is this player\'s number
* @param team is this player\'s team name
* @param symbol is a character (char) representation of this player
* @param x is the x-coordinate of this player
* @param y is the y-coordinate of this player
*/
public Player(Field f, int side, String name, int number, String team, char symbol, double x,
double y){
super(symbol, x, y);
this.name = name;
this.number = number;
this.team = team;
f.registerPlayer(this, this.id, side); // register the player on the field
}
/** attempt to catch an opponent player
*
* @param opponent a player on the opponent\'s team that you are trying to catch
* @param field is the field the game is being played on
* @return true if this player successfully catches the opponent player, false otherwise
*/
public final boolean catchOpponent(Player opponent, Field field){
return field.catchOpponent(this, opponent);
}
/** Informs this player that they have been caught by another player.
*
* This method should only be called from within the Field class.
*
* @param opponent is the player that caught this player
* @param id should be the id of the this player
*/
public void beenCaught(Player opponent, int id){
/* check if the caller knows this entity\'s id */
if( this.id != id ){
throw new SecurityException(\"Unauthorized attempt to call beenCaught \");
}
}
/** att.
java write a program to evaluate the postfix expressionthe program.pdfarjuntelecom26
java write a program to evaluate the postfix expression
the program should ask users for input and show the postfix epression and then the result.
and to have a try and catch exception since we have an empty stack
Solution
Postfix.java
import java.util.Scanner;
public class Postfix
{
/**
* Reads and evaluates multiple postfix expressions.
*/
public static void main (String[] args)
{
String expression, again;
int result;
try
{
Scanner in = new Scanner(System.in);
do
{
PostfixEvaluator evaluator = new PostfixEvaluator();
System.out.println (\"Enter a valid postfix expression: \");
expression = in.nextLine();
result = evaluator.evaluate (expression);
System.out.println();
System.out.println (\"That expression equals \" + result);
System.out.print (\"Evaluate another expression [Y/N]? \");
again = in.nextLine();
System.out.println();
}
while (again.equalsIgnoreCase(\"y\"));
}
catch (Exception IOException)
{
System.out.println(\"Input exception reported\");
}
}
}
PostfixEvaluator.java
//import datastructures.ArrayStack;
import java.util.StringTokenizer;
public class PostfixEvaluator
{
/** constant for addition symbol */
private final char ADD = \'+\';
/** constant for subtraction symbol */
private final char SUBTRACT = \'-\';
/** constant for multiplication symbol */
private final char MULTIPLY = \'*\';
/** constant for division symbol */
private final char DIVIDE = \'/\';
/** the stack */
private ArrayStack stack;
/**
* Sets up this evaluator by creating a new stack.
*/
public PostfixEvaluator()
{
stack = new ArrayStack();
}
/**
* Evaluates the specified postfix expression. If an operand is
* encountered, it is pushed onto the stack. If an operator is
* encountered, two operands are popped, the operation is
* evaluated, and the result is pushed onto the stack.
* //param expr String representation of a postfix expression
* //return int value of the given expression
*/
public int evaluate (String expr)
{
int op1, op2, result = 0;
String token;
StringTokenizer tokenizer = new StringTokenizer (expr);
while (tokenizer.hasMoreTokens())
{
token = tokenizer.nextToken();
if (isOperator(token))
{
op2 = (stack.pop()).intValue();
op1 = (stack.pop()).intValue();
result = evalSingleOp (token.charAt(0), op1, op2);
stack.push (new Integer(result));
}
else
stack.push (new Integer(Integer.parseInt(token)));
}
return result;
}
/**
* Determines if the specified token is an operator.
* //param token String representing a single token
* //return boolean true if token is operator
*/
private boolean isOperator (String token)
{
return ( token.equals(\"+\") || token.equals(\"-\") ||
token.equals(\"*\") || token.equals(\"/\") );
}
/**
* Performs integer evaluation on a single expression consisting of
* the specified operator and operands.
* //param operation operation to be performed
* //param op1 the first operand
* //param op2 the second operand
* //return int value of the expression
*/
private int evalSingleOp (char operation, int op1, int op2)
{
int result = 0;
switch .
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
Frequency .java
/**
* Word frequency counter
*/
package frequency;
import java.util.Iterator;
/**
*
* @author UMD CS
*/
public class Frequency implements Iterable{
private Node first;
private int N;
Frequency(){
N = 0;
first = null;
}
@Override
public Iterator iterator() {
return new ListIterator();
}
/**
*
* List iterator
*
*/
private class ListIterator implements Iterator{
private Node current;
private int index ;
ListIterator(){
current = first;
index = 0;
}
@Override
public boolean hasNext() {
return current != null;
}
public String next() {
if(!hasNext()){
return null;
}
String word = current.key;
int count = current.count;
String r = \"(\"+word + \",\" + Integer.toString(count)+\")\";
current = current.next;
return r;
}
@Override
public void remove() {
}
}
/**
*
* Node class
*
*/
private class Node {
private String key;
private int count;
private Node next;
Node(String item){
key = item;
count = 1;
next = null;
}
@Override
public String toString(){
return \"(\"+key +\",\"+count+\")\";
}
}
/*
* Inserts a word into the linked list. If the word exists, increment the
* count by q.
*/
public void insert(String word){
if(word.equals(\"\")){
return;
}
//TODO
/*
* implement here
*/
}
/**
*
* @param str input string
* This method splits a string into words and pass the words to insert method
*
*/
public void insertWords(String str){
String delims = \"[ .,?!\'\\\"()}{;/<>&=#-:\\\\ _]+\";
String[] words = str.split(delims);
for(String s: words){
s = s.toLowerCase();
insert(s);
}
}
/**
* prints the word frequency list
*/
public void print(){
Node c = first;
while(c != null){
System.out.print(\"(\"+c.key + \",\" + c.count+\")\");
c = c.next;
}
System.out.print(\"\ \");
}
}
--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------
WordFrequency.java
package frequency;
import utils.In;
import utils.Stopwatch;
/**
*
* @author UMD CS
*/
public class WordFrequency {
/**
* @param input source
* @param
* This method receives input resource and return the word frequency string
* DO NOT CHANGE THIS METHOD.
*/
public static String freq(String inputSource, int maxLines){
In in;
// Frequency class can only count the frequency of strings. DO NOT CHANGE THIS.
Frequency freq = new Frequency();
int MAX = 100;
String inputSourceName = inputSource;
try {
in = new In(inputSourceName);
while (!in.isEmpty()) {
String s = in.readLine();
//System.out.println(s);
freq.insertWords(s);
}
}
catch (Exception e) {
e.printStackTrace();
}
StringBuilder strFrequency = new StringBuilder();
int cnt = 0;
for(String s: freq){
strFrequency.append(s);
strFrequency.append(\",\");
cnt++;
if(cnt >= maxLines){break;}
}
return strFrequency.toString();
}
/**
*
*/
public static void main(String[] args) {
In in;
Frequency freq = new Frequency();
int MAX = 100;
// String inputSourceName =
\"http://www.cs.umd.edu/class/summer2015/cmsc132/projects/P3_WordFrequency/test1.html\";
String .
Here are the instructions and then the code in a sec. Please R.pdfaggarwalshoppe14
Here are the instructions and then the code in a sec.
**Please Resubmit the revised and updated Code (GamerService) with Comments added
explaining please. RIGHT***** JAVA. HOWEVER IF YOU NEED TO CHANGE THE
ENTIRE THING IT IS FINE. I AM DESPERATE.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
Repeat Programming Project 2 in Chapter 5. This time, add the following four constructor
methods: one for each instance variable, one with two parameters for the two instance variables,
and a default constructor. Be sure that each constructor sets all the instance variables. write a
driver program to test each of the methods, including each of the four constructors and at least
one true or false case for each of the test method.
this is the code that i have to add four constructor methods to
import java.util.*;
public class PersonImproved// Counter is the name of the class and i saved it in a file named
PersonImproved.
{
//Data members
private String name;
private int age;
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println(\"What is the person\'s name?\");// This gets the program ready for
keyboard input by telling us that there is a new scanner called keyboard, that is accepting user
input.
name = keyboard.nextLine();
System.out.println(\"What is the person\'s age?\");
age = keyboard.nextInt();
while (age < 0)
{
System.out.println(\"Age cannot be negative.\");
System.out.println(\"Reenter age:\");
age = keyboard.nextInt();
}
}
public void writeOutput()
{
System.out.println(\"Name = \" + name);
System.out.println(\"Age = \" + age);
}
//method to set non negative age
public void set(String newName, int newAge)
{
name = newName;
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
}
//method to setting name
public void setName(String newName)
{
name = newName;
}
//method to set age
public void setAge(int newAge)
{
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
} //to get name
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
/*Boolean tests for if two persons are equal (same name and age), if two persons
have the same name, if two persons have the same age, if one person is older
than another, and if one person is younger than another.*/
public boolean equals(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name)
&& this.getAge() == another.getAge());
}
public boolean isSameName(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name));
}
public boolean isSameAge(PersonImproved another)
{
return(this.getAge() == another.getAge());
}
public boolean isOlderThan(PersonImproved another)
{
return(this.getAge() > another.getAge());
}
public boolean isYoungerThan(PersonImproved
another)
{
return(this.getAge() < another.getAge());
}
}
and this is the test file
public class PersonCh6Test
{
public static void main(String[] args)
{
System.out.println();
System.out.println(\"Test case 1: default constructor and\");
System.out.println(\"writeOutput() method.\");
System.out.println();
PersonCh6 secretAgent1 = new PersonCh6();
System.out.println(\"Results of default constructor:\");
System.out.println(\"Should be name = \\\"No name\\\" and\");
S.
Tested on Eclipse and both class should be in same packageimport.pdfanuradhasilks
//Tested on Eclipse and both class should be in same package
import java.util.Scanner;
public class P3 {
/*isInteger method implementation
* @param String type
* while parsing if it throw exception then it is not integer
* else it is integer*/
public static Boolean isDouble(String token){
try {
Double.parseDouble(token);
} catch(NumberFormatException e) {
System.out.println(\"Invalid Operand\");
return false;
} catch(NullPointerException e) {
System.out.println(\"Invalid Operand\");
return false;
}
// only got here if we didn\'t return false
return true;
}
public static String evaluate(String expression) {
// Print expression
System.out.print(expression);
// Declare variables for operands, operator, result, and return value
double operand1=0,operand2 = 0,result=0;
char operator;
Boolean flag=Boolean.FALSE;//for if operators were not listed
String returnString = \"\";
String token[]=new String[expression.length()];//for storing all token from expression
// Create Scanner object to parse expression
// create a new scanner with the specified String Object
int i=0;
Scanner scanner = new Scanner(expression);
while(scanner.hasNext()){
token[i]=scanner.next();
i++;
}
scanner.close();
// Compute a numerical result for the expression
if(isDouble(token[0])){
operand1=Double.parseDouble(token[0]);
}
if(isDouble(token[2])){
operand2=Double.parseDouble(token[2]);
}
operator=token[1].charAt(0);
if(operand1!=0&&operand2!=0){
switch(operator){
case \'+\':
result=operand1+operand2;
break;
case \'-\':
result=operand1-operand2;
break;
case \'*\':
result=operand1*operand2;
break;
case \'/\':
result=operand1/operand2;
break;
case \'%\':
result=operand1%operand2;
break;
case \'^\':
result=Math.pow(operand1, operand2);
break;
default:
System.out.println(\"Invalid Operator\");
flag=Boolean.TRUE;
break;
}
// Convert numerical result to string
returnString=Double.toString(result);
if(flag){
return null;
}
// Return result
return returnString;
}else{
return null;
}
}
}
/*********Calculator class***************/
import java.util.Scanner;
/*Calculator class start*/
public class Calculator {
public static void main(String args[]){
/*Variable declaration*/
String expression;
/*Scanner object for input*/
Scanner input=new Scanner(System.in);
/*Prompt for expression*/
System.out.println(\"Please Enter expression\");
expression=input.nextLine();
input.close();
/*Calling Evaluate method*/
String result=P3.evaluate(expression);
/*Printing result if it is not null*/
if(result!=null) {
System.out.println(result);
}
}
}
/***************output************/
Please Enter expression
11.22 + 3.456 =
11.22 + 3.456 =14.676
Please Enter expression
5.555 - 32.14 =
5.555 - 32.14 =-26.585
Please Enter expression
25634.8 * .32 =
25634.8 * .32 = 8203.136
Please Enter expression
5 ^ 4 =
5 ^ 4 =625.0
Please Enter expression
Whatever + 2 =
Whatever + 2 =Invalid Operand
Please Enter expression
4.0 - 1.2.3 =
4.0 - 1.2.3 =Invalid Operand
Please Enter expression
1.234 $ 0.5 =
1.234 $ 0.5 =Invalid Ope.
I really need some help if I have this right so far. PLEASE CHANG.pdfaggarwalshoppe14
I really need some help if I have this right so far. ***PLEASE CHANGE COMMENTS TO
EXPLAIN THE JAVA APPLICATION OR IF CHANGE THE CODE SO IT CAN BE
RIGHT***** JAVA
Here are the instructions and then the code in a sec.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.java
Player.java
GameService.j.
C# Program. Create a Windows application that has the functionality .pdffathimalinks
C# Program. Create a Windows application that has the functionality of a calculator and works
with integral values. Allow the user to select buttons representing numeric values. If the user
attempts to divide by zero, throw and handle an exception.
Solution
below is the code from the windows application in visual studio:
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SimpleCalculator
{
public partial class frmCalculator : Form
{
string operand1 = string.Empty;
string operand2 = string.Empty;
string result;
char operation;
public frmCalculator()
{
InitializeComponent();
}
private void frmCalculator_Load(object sender, EventArgs e)
{
btnOne.Click += new EventHandler(btn_Click);
btnTwo.Click += new EventHandler(btn_Click);
btnThree.Click += new EventHandler(btn_Click);
btnFour.Click += new EventHandler(btn_Click);
btnFive.Click += new EventHandler(btn_Click);
btnSix.Click += new EventHandler(btn_Click);
btnSeven.Click += new EventHandler(btn_Click);
btnEight.Click += new EventHandler(btn_Click);
btnNine.Click += new EventHandler(btn_Click);
btnZero.Click += new EventHandler(btn_Click);
btnDot.Click += new EventHandler(btn_Click);
}
void btn_Click(object sender, EventArgs e)
{
try
{
Button btn = sender as Button;
switch (btn.Name)
{
case \"btnOne\":
txtInput.Text += \"1\";
break;
case \"btnTwo\":
txtInput.Text += \"2\";
break;
case \"btnThree\":
txtInput.Text += \"3\";
break;
case \"btnFour\":
txtInput.Text += \"4\";
break;
case \"btnFive\":
txtInput.Text += \"5\";
break;
case \"btnSix\":
txtInput.Text += \"6\";
break;
case \"btnSeven\":
txtInput.Text += \"7\";
break;
case \"btnEight\":
txtInput.Text += \"8\";
break;
case \"btnNine\":
txtInput.Text += \"9\";
break;
case \"btnZero\":
txtInput.Text += \"0\";
break;
case \"btnDot\":
if(!txtInput.Text.Contains(\".\"))
txtInput.Text += \".\";
break;
}
}
catch(Exception ex)
{
MessageBox.Show(\"Sorry for the inconvenience, Unexpected error occured. Details:
\" +
ex.Message);
}
}
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case \'1\':
case \'2\':
case \'3\':
case \'4\':
case \'5\':
case \'6\':
case \'7\':
case \'8\':
case \'9\':
case \'0\':
//case \'+\':
//case \'-\':
//case \'*\':
//case \'/\':
//case \'.\':
break;
default:
e.Handled = true;
MessageBox.Show(\"Only numbers, +, -, ., *, / are allowed\");
break;
}
}
private void txtInput_TextChanged(object sender, EventArgs e)
{
}
private void btnPlus_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'+\';
txtInput.Text = string.Empty;
}
private void btnMinus_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'-\';
txtInput.Text = string.Empty;
}
private void btnMulitply_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'*\';
txtInput.Text = string.Empty;
}
private void btnDivide_Click.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
I really need some help if I have this right so far. Please Resub.pdfaggarwalshoppe14
I really need some help if I have this right so far. ***Please Resubmit the revsised and updated
Code with Comments added explaining please. RIGHT***** JAVA
Here are the instructions and then the code in a sec.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.java
Player.java
GameService.java
P.
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docxraju957290
MIS 4310-01 Final Take Home Exam (100 points)
DUE: Thursday, December 14th, 2017 by 11:59 PM
Use the code provided on Blackboard as your template. Fill in your own code where
prompted. When finished, upload to Blackboard a file called “treasure_hunt.java”. Change
the block comment to include your own name. This is an individual assignment! Code that
you write that you cannot explain will result in an automatic zero.
Create a Java application that simulates a treasure hunt with a 2D array. Your output
should match the output below with similar input. Do NOT alter the code provided. Fill
in code in the SEVEN (7) locations under each comment // YOUR CODE HERE.
Sample Output:
import java.util.Random;
import java.util.Scanner;
/*
* First Last
* MIS 4310 Fall 2017
* FINAL TAKE HOME EXAM
*/
public class treasure_hunt {
public static void main(String[] args) {
boolean found = false; // is true if the treasure is found
int dug = 0; // holds the number of times user digs
Random gen = new Random(9);
Scanner scan = new Scanner(System.in);
int locationRow; // stores the row where the treasure is
int locationCol; // stores the column where the treasure is
/*
* Generates a String array that looks like
* undug grass when printed to represent the backyard.
*/
String[][] backyard = new String[5][5];
for (int row = 0; row < backyard.length; row++) {
for (int col = 0; col < backyard[row].length; col++) {
backyard[row][col] = "^";
System.out.print(backyard[row][col] + " ");
} // end inner loop
System.out.println();
} // end outer loop
/*
* Generate a random number for both the row and column
* location of the treasure. Store the results in
* locationRow and locationCol, respectively.
* The random numbers should be within the array dimensions.
*/
//**************************
// YOUR CODE HERE (1 OF 7)
//**************************
/*
* A while loop that runs as long as the treasure
* is not found.
*/
while (found == false) {
/*
* Declare two integer variables, guessRow and guessCol
* and set them both to -1.
* Increment the variable dug to represent a dig.
*/
//**************************
// YOUR CODE HERE (2 OF 7)
//**************************
/*
* Ask the user which row they want to dig.
* Use a while loop to validate the input.
* Run the while loop as long as the guessRow
* value is outside the bounds of the array.
*/
//**************************
// YOUR CODE HERE (3 OF 7)
//**************************
/*
* Ask the user which column they want to dig.
* Use a while loop to validate the input.
* Run the while loop as long as the guessCol
* value is outside the bounds of the array.
*/
...
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
Please read the comment ins code
ExpressionTree.java
----------------------------------
/**
* This is the class for Expression Tree.
* Used to create Expression Tree and Evaluate it
*/
/**
* Following logic is used to construct a Tree
* Here we use stack for Preparing Tree
* Loop through given Expression String
* If Character is Operand , Create node and push to stack
* If Character is Operator then
* 1)Create Node for Operator
* 2)Pop 2 nodes from Stack and Made
* OpretorNode--> left == first node pop
* OpretorNode--> right == second node pop
* At the end of creation of Expression Tree, Stack have only one node , which is root of
Expression tree
*/
/** Class ExpressionTree **/
class ExpressionTree
{
/** class TreeNode
* Stored Character ==> Digit(0..9) or a Operator +,-,*,/
* Left Node and Right Node
*
* **/
class TreeNode
{
char data;
TreeNode left, right;
/** constructor **/
public TreeNode(char data)
{
this.data = data;
this.left = null;
this.right = null;
}
}
/** class StackNode **/
class StackNode
{
TreeNode treeNode;
StackNode next;
/** constructor **/
public StackNode(TreeNode treeNode)
{
this.treeNode = treeNode;
next = null;
}
}
private static StackNode top;
/** constructor
* Constructor takes input string like \"+-+7*935*82*625\"
* Input should be in Prefix notation
* **/
public ExpressionTree(String expression)
{
top = null;
//Call Method for prepare expression tree
buildTree(expression);
}
/** function to clear tree **/
public void clear()
{
top = null;
}
/** function to push a node **/
private void push(TreeNode ptr)
{
if (top == null)
top = new StackNode(ptr);
else
{
StackNode nptr = new StackNode(ptr);
nptr.next = top;
top = nptr;
}
}
/** function to pop a node
* When it find operator pop 2 elements from Stack
*
* **/
private TreeNode pop()
{
if (top == null)
throw new RuntimeException(\"Underflow\");
else
{
TreeNode ptr = top.treeNode;
top = top.next;
return ptr;
}
}
/** function to get top node **/
private TreeNode peek()
{
return top.treeNode;
}
/** function to insert character **/
private void insert(char val)
{
try
{
//If Operand , Create node and push to Stack
if (isDigit(val))
{
TreeNode nptr = new TreeNode(val);
push(nptr);
}
//If Operator , Create node and popup 2 elements and make them its right and left
else if (isOperator(val))
{
TreeNode nptr = new TreeNode(val);
nptr.left = pop();
nptr.right = pop();
push(nptr);
}
}
catch (Exception e)
{
System.out.println(\"Invalid Expression\");
}
}
/** function to check if digit **/
private boolean isDigit(char ch)
{
return ch >= \'0\' && ch <= \'9\';
}
/** function to check if operator **/
private boolean isOperator(char ch)
{
return ch == \'+\' || ch == \'-\' || ch == \'*\' || ch == \'/\';
}
/** function to convert character to digit **/
private int toDigit(char ch)
{
return ch - \'0\';
}
/** function to build tree from input */
public void buildTree(String eqn)
{
for (int i = eqn.length() - 1; i >= 0; i--)
insert(eqn.charAt(i));
}
/** function to evaluate tree */
public dou.
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
Create a C# application
You are to create a class object called “Employee” which included eight private variables:
firstN
lastN
dNum
wage: holds how much the person makes per hour
weekHrsWkd: holds how many total hours the person worked each week.
regHrsAmt: initialize to a fixed amount of 40 using constructor.
regPay
otPay
After going over the regular hours, the employee gets 1.5x the wage for each additional hour
worked.
Methods:
constructor
properties
CalcPay(): Calculate the regular pay and overtime pay.
Create an “EmployeeDemo” class. In the main function, the program should ask the user the
number of employee in the company and create a 2-dimensional dynamic array (number of
employee by 4 weeks). Then, the program should ask user to enter each employee’s information
and the amount of hours they worked weekly.
The program shows a menu with employee name for user to choose which employee to display
the following information:
How much the person totally made
How much of paycheck is regular pay
How much of paycheck is overtime pay
Solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Employee
{
public enum EmployeeType {GROUPA, GROUPB, GROUPC, GROUPD};
public struct EmployeeSalaryInfo
{
public float hourlyWage;
public int monthlyHours;
public float baseSalary;
public int numSales;
public EmployeeSalaryInfo( EmployeeType eme)
{
this.hourlyWage = 0;
this.monthlyHours = 0;
this.baseSalary = 0;
this.numSales = 0;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(\"Welcome to the Employee System\");
EmployeeArray empArray = new EmployeeArray();
int continueRunning = 1;
do
Console.WriteLine();
Console.WriteLine(\"Please Enter Your Choice:\");
Console.WriteLine(\"1=Enter new employee\");
Console.WriteLine(\"2=Update existing employee\");
Console.WriteLine(\"3=Delete employee\");
Console.WriteLine(\"4=Print employee list\");
Console.WriteLine(\"Any other number to Exit\");
int userChoice = int.Parse(Console.ReadLine());
Console.WriteLine();
switch (userChoice)
{
case 1:
Employee emp = CreateNewWorker(); //Asking for employee information by
creating a new employee.
if (!(empArray.Contains(emp))) //Checking to see that employee does not
exist
empArray.Add(emp); //If the employee does not exist in the list then
we can add it.
else
Console.WriteLine(\"Can not add new worker. This worker already exists\");
break;
case 2: //If user wishes to edit an employee
EditEmployee(empArray);
break;
case 3:
DeleteEmployee(empArray); //if user wishes to delete an employee from
the list
break;
case 4:
empArray.Print();
break;
default:
continueRunning = 0; //If user has chosen to exit the system.
break;
}
} while (continueRunning == 1); //Checking to see if to continue running
the system
}
static Employee CreateNewWorker() //Method for creating a
new employee.
{
Employee emp; //A new employee consists of
the basic information which is
Console.WriteLine(\"Enter first name.
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD
OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE
PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE
MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS.
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below
Read gamescore.txt to initialize the Linked list in sorted order by score.
Ask the user to add or remove users to update the sorted linked list.
Display “Name exist” when add an exist name to the list.
Display “Name does not exist” when remove a name not on the list.
List.java File:
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List
{
/**
* Remove all contents from the list, so it is once again empty. Client is
* responsible for reclaiming storage used by the list elements.
*/
public void clear();
/**
* Insert an element at the current location. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be inserted.
*/
public void insert(E item);
/**
* Append an element at the end of the list. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be appended.
*/
public void append(E item);
/**
* Remove and return the current element.
*
* @return The element that was removed.
*/
public E remove();
/** Set the current position to the start of the list */
public void moveToStart();
/** Set the current position to the end of the list */
public void moveToEnd();
/**
* Move the current position one step left. No change if already at
* beginning.
*/
public void prev();
/**
* Move the current position one step right. No change if already at end.
*/
public void next();
/** @return The number of elements in the list. */
public int length();
/** @return The position of the current element. */
public int currPos();
/**
* Set current position.
*
* @param pos
* The position to make current.
*/
public void moveToPos(int pos);
/** @return The current element. */
public E getValue();
}
LList.java File:
/**
* Source code example for \"A Practical Introduction to Data Structures and
* Algorithm Analysis, 3rd Edition (Java)\" by Clifford A. Shaffer Copyright
* 2008-2011 by Clifford A. Shaffer
*/
// Doubly linked list implementation
class LList implements List
{
private DLink head; // Pointer to list header
private DLink tail; // Pointer to last element in list
protected DLink curr; // Pointer ahead of current element
int cnt; // Size of list
// Constructors
LList(int size)
{
th.
week3_src/DoWhileLoopFactorial.javaweek3_src/DoWhileLoopFactorial.javapackage edu.drexel.ct290;
import java.util.Scanner;
publicclassDoWhileLoopFactorial{
/**
* A factorial is calculated by multiplying a number by
* every integer less than itself except zero. For example the
* factorial of 4, written 4!, is 4*3*2*1 = 24.
*/
publiclong calculateFactorial(int number){
// declare and initialize a variable to hold the answer
long factorial=number;
// the do while loop will run the block of code between the braces
// as long as the condition in the while statement is true.
// The different between this and the while loop is that
// here, the code will always execute at least once.
do{
// the print statement can help debug errors is in the code
System.out.println("Fact: "+ factorial +", number: "+ number);
// calculate the next factor
factorial = factorial *(number-1);
// decrement the number so that the next iteration of the loop
// will have the correct value to multiply
number--;
}
while( number >1);
// return the answer to the caller.
return factorial;
}
publicstaticvoid main(String[] args){
// Get the user input
Scanner reader =newScanner(System.in);
System.out.print("What number do you want a factorial for: ");
int number = reader.nextInt();
// Create a DoWhileLoopFactorial class
DoWhileLoopFactorial loopFactorial =newDoWhileLoopFactorial();
// call calculateFactorial to compute the answer
long factorial = loopFactorial.calculateFactorial( number );
// Show the user the answer
System.out.println("The answer is: "+ factorial);
}
}
__MACOSX/week3_src/._DoWhileLoopFactorial.java
week3_src/ForLoopFactorial.javaweek3_src/ForLoopFactorial.javapackage edu.drexel.ct290;
import java.util.Scanner;
publicclassForLoopFactorial{
/**
* A factorial is calculated by multiplying a number by
* every integer less than itself except zero. For example the
* factorial of 4, written 4!, is 4*3*2*1 = 24.
*/
publiclong calculateFactorial(int number){
// declare and initialize a variable to hold the answer
long factorial = number;
// The for loop has three parts:
// initialization: int i=number;
// condition: i>1;
// increment/decrement: i--;
// The variable in the initialization is called the control variable
// The initialization happens once when the loop starts.
// The loop will execute as long as the condition is true.
// The decrement will happen automatically after each iteration.
for(int i=number; i>1; i--){
// the print statement can help debug errors is in the code
System.out.println("Fact: "+ factorial +", i: "+ i);
// calculate the next factor
factorial = factorial *(i-1);
}
// return the answer to the caller.
return factorial;
}
publicstaticvoid main(String[] args){
// Get the user input
Scanner reader =newScanner(System.in);
System.out.print("What number do you want a factorial for: ");
int number = reader.nextInt();
// Create a WhileLoopFactoria.
SeriesTester/.classpath
SeriesTester/.project
SeriesTester
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
SeriesTester/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
SeriesTester/bin/seriesTester/FibonacciSequence.classpackage seriesTester;
publicsynchronizedclass FibonacciSequence {
private int firstNumber;
private int secondNumber;
public void FibonacciSequence();
public boolean validStartNumbers(int, int);
public void printSequence(int);
public void printSequence(int, int, int);
private void setSecondNumber(int);
private void setFirstNumber(int);
public void resetSequence();
}
SeriesTester/bin/seriesTester/PowerSeries.classpackage seriesTester;
publicsynchronizedclass PowerSeries {
private math2 myMath;
private double value_of_x;
private double number_of_terms;
public void PowerSeries();
public void setX(double);
public void setNumOfTerms(double);
public double run_eTo_xSeries();
public double run_sin_Of_xSeries();
public double run_PowerSeries();
}
SeriesTester/bin/seriesTester/SeriesTester.classpackage seriesTester;
publicsynchronizedclass SeriesTester {
privatestatic java.util.Scanner keyboard;
privatestatic FibonacciSequence myFibonacci;
privatestatic PowerSeries myPower;
static void <clinit>();
public void SeriesTester();
publicstatic void main(String[]);
privatestatic void powerSeries();
privatestatic void fibonociiSeries();
privatestatic String selectSerries();
}
SeriesTester/bin/seriesTester/math2.classpackage seriesTester;
publicsynchronizedclass math2 {
public void math2();
public int factorial(int);
}
SeriesTester/src/seriesTester/SeriesTester.javaSeriesTester/src/seriesTester/SeriesTester.javapackage seriesTester;
import java.util.Scanner;
publicclassSeriesTester
{
/**
* @param args
* Author Larry R Shannon This is the demo/testing program for the
* Fibonacci/Power series project. The algorithm for the demo part of
* this project is as follows: Variables needed: State Variables:
* Scanner keyboard is used to read data from the input data buffer.
* (the keyboard) FibonacciSequence myFibonacci is the class object
* that contains the data and methods needed to explore the Fi.
Which one of the following is NOT a social trend that is currently af.pdffathimahardwareelect
Which one of the following is NOT a social trend that is currently affecting how individuals
behave and set up priorities? A. Growth in the use of mobile devices O B. Passage &t; the
Affordable Care Act (Obamacare) O C. Aging of the population O D. The increasing diversity of
the workforce E. Increased participation in social networks Click to select your answer
Solution
Ans
The increased diversity of workforce. It affects individual behavior but not his priorities.
Which of the following is normally a major activity of materials man.pdffathimahardwareelect
Which of the following is normally a major activity of materials management? I. Manufacturing
planning and control II. Physical supply/distribution a. both I and II b. neither I nor II c. I only d.
II only
Solution
material management is focus on all the activities of manufacturing planning, control, supply of
the goods and distribution of the goods.
so, option A is correct.
More Related Content
Similar to ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfshahidqamar17
question.(player, entity ,field and base.java codes are given)
Stopping Player
All players need to stay within the eld boundaries. This rst class you write will lay some of the
foundation for the logic needed in all your players. Create a class called Stopping that extends
the Player class. A Stopping player will initially move in a random direction and stops moving
when it reaches the border of the playing eld (without leaving the playing eld). The direction that
a player moves in is determined by its speed in each direction: speedX and speedY. You will add
this logic to manipulate the speed attributes for stopping in its play() method. Take care to notice
that the images of the players have some size to them. Your player should not “visually” leave
the eld. All parts of the image should be on or inside the eld boundaries.
player class;
public abstract class Player extends Entity{
/** this player\'s team name */
protected String team;
/** this player\'s name */
protected String name;
/** this player\'s number */
protected int number;
/** gets this player\'s team name
*
* @return the team name that this player is on
*/
public final String getTeam(){ return this.team; }
/** gets this player\'s name
*
* @return the name of this player
*/
public final String getName(){ return this.name; }
/** gets this player\'s number
*
* @return the number of this player
*/
public final int getNumber(){ return this.number; }
/** creates a player with specified symbol at specified position
*
* @param f is the field the player will be playing on
* @param side is the side of the field the player will play on
* @param name is this name of the player
* @param number is this player\'s number
* @param team is this player\'s team name
* @param symbol is a character (char) representation of this player
* @param x is the x-coordinate of this player
* @param y is the y-coordinate of this player
*/
public Player(Field f, int side, String name, int number, String team, char symbol, double x,
double y){
super(symbol, x, y);
this.name = name;
this.number = number;
this.team = team;
f.registerPlayer(this, this.id, side); // register the player on the field
}
/** attempt to catch an opponent player
*
* @param opponent a player on the opponent\'s team that you are trying to catch
* @param field is the field the game is being played on
* @return true if this player successfully catches the opponent player, false otherwise
*/
public final boolean catchOpponent(Player opponent, Field field){
return field.catchOpponent(this, opponent);
}
/** Informs this player that they have been caught by another player.
*
* This method should only be called from within the Field class.
*
* @param opponent is the player that caught this player
* @param id should be the id of the this player
*/
public void beenCaught(Player opponent, int id){
/* check if the caller knows this entity\'s id */
if( this.id != id ){
throw new SecurityException(\"Unauthorized attempt to call beenCaught \");
}
}
/** att.
java write a program to evaluate the postfix expressionthe program.pdfarjuntelecom26
java write a program to evaluate the postfix expression
the program should ask users for input and show the postfix epression and then the result.
and to have a try and catch exception since we have an empty stack
Solution
Postfix.java
import java.util.Scanner;
public class Postfix
{
/**
* Reads and evaluates multiple postfix expressions.
*/
public static void main (String[] args)
{
String expression, again;
int result;
try
{
Scanner in = new Scanner(System.in);
do
{
PostfixEvaluator evaluator = new PostfixEvaluator();
System.out.println (\"Enter a valid postfix expression: \");
expression = in.nextLine();
result = evaluator.evaluate (expression);
System.out.println();
System.out.println (\"That expression equals \" + result);
System.out.print (\"Evaluate another expression [Y/N]? \");
again = in.nextLine();
System.out.println();
}
while (again.equalsIgnoreCase(\"y\"));
}
catch (Exception IOException)
{
System.out.println(\"Input exception reported\");
}
}
}
PostfixEvaluator.java
//import datastructures.ArrayStack;
import java.util.StringTokenizer;
public class PostfixEvaluator
{
/** constant for addition symbol */
private final char ADD = \'+\';
/** constant for subtraction symbol */
private final char SUBTRACT = \'-\';
/** constant for multiplication symbol */
private final char MULTIPLY = \'*\';
/** constant for division symbol */
private final char DIVIDE = \'/\';
/** the stack */
private ArrayStack stack;
/**
* Sets up this evaluator by creating a new stack.
*/
public PostfixEvaluator()
{
stack = new ArrayStack();
}
/**
* Evaluates the specified postfix expression. If an operand is
* encountered, it is pushed onto the stack. If an operator is
* encountered, two operands are popped, the operation is
* evaluated, and the result is pushed onto the stack.
* //param expr String representation of a postfix expression
* //return int value of the given expression
*/
public int evaluate (String expr)
{
int op1, op2, result = 0;
String token;
StringTokenizer tokenizer = new StringTokenizer (expr);
while (tokenizer.hasMoreTokens())
{
token = tokenizer.nextToken();
if (isOperator(token))
{
op2 = (stack.pop()).intValue();
op1 = (stack.pop()).intValue();
result = evalSingleOp (token.charAt(0), op1, op2);
stack.push (new Integer(result));
}
else
stack.push (new Integer(Integer.parseInt(token)));
}
return result;
}
/**
* Determines if the specified token is an operator.
* //param token String representing a single token
* //return boolean true if token is operator
*/
private boolean isOperator (String token)
{
return ( token.equals(\"+\") || token.equals(\"-\") ||
token.equals(\"*\") || token.equals(\"/\") );
}
/**
* Performs integer evaluation on a single expression consisting of
* the specified operator and operands.
* //param operation operation to be performed
* //param op1 the first operand
* //param op2 the second operand
* //return int value of the expression
*/
private int evalSingleOp (char operation, int op1, int op2)
{
int result = 0;
switch .
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
Frequency .java
/**
* Word frequency counter
*/
package frequency;
import java.util.Iterator;
/**
*
* @author UMD CS
*/
public class Frequency implements Iterable{
private Node first;
private int N;
Frequency(){
N = 0;
first = null;
}
@Override
public Iterator iterator() {
return new ListIterator();
}
/**
*
* List iterator
*
*/
private class ListIterator implements Iterator{
private Node current;
private int index ;
ListIterator(){
current = first;
index = 0;
}
@Override
public boolean hasNext() {
return current != null;
}
public String next() {
if(!hasNext()){
return null;
}
String word = current.key;
int count = current.count;
String r = \"(\"+word + \",\" + Integer.toString(count)+\")\";
current = current.next;
return r;
}
@Override
public void remove() {
}
}
/**
*
* Node class
*
*/
private class Node {
private String key;
private int count;
private Node next;
Node(String item){
key = item;
count = 1;
next = null;
}
@Override
public String toString(){
return \"(\"+key +\",\"+count+\")\";
}
}
/*
* Inserts a word into the linked list. If the word exists, increment the
* count by q.
*/
public void insert(String word){
if(word.equals(\"\")){
return;
}
//TODO
/*
* implement here
*/
}
/**
*
* @param str input string
* This method splits a string into words and pass the words to insert method
*
*/
public void insertWords(String str){
String delims = \"[ .,?!\'\\\"()}{;/<>&=#-:\\\\ _]+\";
String[] words = str.split(delims);
for(String s: words){
s = s.toLowerCase();
insert(s);
}
}
/**
* prints the word frequency list
*/
public void print(){
Node c = first;
while(c != null){
System.out.print(\"(\"+c.key + \",\" + c.count+\")\");
c = c.next;
}
System.out.print(\"\ \");
}
}
--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------
WordFrequency.java
package frequency;
import utils.In;
import utils.Stopwatch;
/**
*
* @author UMD CS
*/
public class WordFrequency {
/**
* @param input source
* @param
* This method receives input resource and return the word frequency string
* DO NOT CHANGE THIS METHOD.
*/
public static String freq(String inputSource, int maxLines){
In in;
// Frequency class can only count the frequency of strings. DO NOT CHANGE THIS.
Frequency freq = new Frequency();
int MAX = 100;
String inputSourceName = inputSource;
try {
in = new In(inputSourceName);
while (!in.isEmpty()) {
String s = in.readLine();
//System.out.println(s);
freq.insertWords(s);
}
}
catch (Exception e) {
e.printStackTrace();
}
StringBuilder strFrequency = new StringBuilder();
int cnt = 0;
for(String s: freq){
strFrequency.append(s);
strFrequency.append(\",\");
cnt++;
if(cnt >= maxLines){break;}
}
return strFrequency.toString();
}
/**
*
*/
public static void main(String[] args) {
In in;
Frequency freq = new Frequency();
int MAX = 100;
// String inputSourceName =
\"http://www.cs.umd.edu/class/summer2015/cmsc132/projects/P3_WordFrequency/test1.html\";
String .
Here are the instructions and then the code in a sec. Please R.pdfaggarwalshoppe14
Here are the instructions and then the code in a sec.
**Please Resubmit the revised and updated Code (GamerService) with Comments added
explaining please. RIGHT***** JAVA. HOWEVER IF YOU NEED TO CHANGE THE
ENTIRE THING IT IS FINE. I AM DESPERATE.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
Repeat Programming Project 2 in Chapter 5. This time, add the following four constructor
methods: one for each instance variable, one with two parameters for the two instance variables,
and a default constructor. Be sure that each constructor sets all the instance variables. write a
driver program to test each of the methods, including each of the four constructors and at least
one true or false case for each of the test method.
this is the code that i have to add four constructor methods to
import java.util.*;
public class PersonImproved// Counter is the name of the class and i saved it in a file named
PersonImproved.
{
//Data members
private String name;
private int age;
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println(\"What is the person\'s name?\");// This gets the program ready for
keyboard input by telling us that there is a new scanner called keyboard, that is accepting user
input.
name = keyboard.nextLine();
System.out.println(\"What is the person\'s age?\");
age = keyboard.nextInt();
while (age < 0)
{
System.out.println(\"Age cannot be negative.\");
System.out.println(\"Reenter age:\");
age = keyboard.nextInt();
}
}
public void writeOutput()
{
System.out.println(\"Name = \" + name);
System.out.println(\"Age = \" + age);
}
//method to set non negative age
public void set(String newName, int newAge)
{
name = newName;
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
}
//method to setting name
public void setName(String newName)
{
name = newName;
}
//method to set age
public void setAge(int newAge)
{
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
} //to get name
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
/*Boolean tests for if two persons are equal (same name and age), if two persons
have the same name, if two persons have the same age, if one person is older
than another, and if one person is younger than another.*/
public boolean equals(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name)
&& this.getAge() == another.getAge());
}
public boolean isSameName(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name));
}
public boolean isSameAge(PersonImproved another)
{
return(this.getAge() == another.getAge());
}
public boolean isOlderThan(PersonImproved another)
{
return(this.getAge() > another.getAge());
}
public boolean isYoungerThan(PersonImproved
another)
{
return(this.getAge() < another.getAge());
}
}
and this is the test file
public class PersonCh6Test
{
public static void main(String[] args)
{
System.out.println();
System.out.println(\"Test case 1: default constructor and\");
System.out.println(\"writeOutput() method.\");
System.out.println();
PersonCh6 secretAgent1 = new PersonCh6();
System.out.println(\"Results of default constructor:\");
System.out.println(\"Should be name = \\\"No name\\\" and\");
S.
Tested on Eclipse and both class should be in same packageimport.pdfanuradhasilks
//Tested on Eclipse and both class should be in same package
import java.util.Scanner;
public class P3 {
/*isInteger method implementation
* @param String type
* while parsing if it throw exception then it is not integer
* else it is integer*/
public static Boolean isDouble(String token){
try {
Double.parseDouble(token);
} catch(NumberFormatException e) {
System.out.println(\"Invalid Operand\");
return false;
} catch(NullPointerException e) {
System.out.println(\"Invalid Operand\");
return false;
}
// only got here if we didn\'t return false
return true;
}
public static String evaluate(String expression) {
// Print expression
System.out.print(expression);
// Declare variables for operands, operator, result, and return value
double operand1=0,operand2 = 0,result=0;
char operator;
Boolean flag=Boolean.FALSE;//for if operators were not listed
String returnString = \"\";
String token[]=new String[expression.length()];//for storing all token from expression
// Create Scanner object to parse expression
// create a new scanner with the specified String Object
int i=0;
Scanner scanner = new Scanner(expression);
while(scanner.hasNext()){
token[i]=scanner.next();
i++;
}
scanner.close();
// Compute a numerical result for the expression
if(isDouble(token[0])){
operand1=Double.parseDouble(token[0]);
}
if(isDouble(token[2])){
operand2=Double.parseDouble(token[2]);
}
operator=token[1].charAt(0);
if(operand1!=0&&operand2!=0){
switch(operator){
case \'+\':
result=operand1+operand2;
break;
case \'-\':
result=operand1-operand2;
break;
case \'*\':
result=operand1*operand2;
break;
case \'/\':
result=operand1/operand2;
break;
case \'%\':
result=operand1%operand2;
break;
case \'^\':
result=Math.pow(operand1, operand2);
break;
default:
System.out.println(\"Invalid Operator\");
flag=Boolean.TRUE;
break;
}
// Convert numerical result to string
returnString=Double.toString(result);
if(flag){
return null;
}
// Return result
return returnString;
}else{
return null;
}
}
}
/*********Calculator class***************/
import java.util.Scanner;
/*Calculator class start*/
public class Calculator {
public static void main(String args[]){
/*Variable declaration*/
String expression;
/*Scanner object for input*/
Scanner input=new Scanner(System.in);
/*Prompt for expression*/
System.out.println(\"Please Enter expression\");
expression=input.nextLine();
input.close();
/*Calling Evaluate method*/
String result=P3.evaluate(expression);
/*Printing result if it is not null*/
if(result!=null) {
System.out.println(result);
}
}
}
/***************output************/
Please Enter expression
11.22 + 3.456 =
11.22 + 3.456 =14.676
Please Enter expression
5.555 - 32.14 =
5.555 - 32.14 =-26.585
Please Enter expression
25634.8 * .32 =
25634.8 * .32 = 8203.136
Please Enter expression
5 ^ 4 =
5 ^ 4 =625.0
Please Enter expression
Whatever + 2 =
Whatever + 2 =Invalid Operand
Please Enter expression
4.0 - 1.2.3 =
4.0 - 1.2.3 =Invalid Operand
Please Enter expression
1.234 $ 0.5 =
1.234 $ 0.5 =Invalid Ope.
I really need some help if I have this right so far. PLEASE CHANG.pdfaggarwalshoppe14
I really need some help if I have this right so far. ***PLEASE CHANGE COMMENTS TO
EXPLAIN THE JAVA APPLICATION OR IF CHANGE THE CODE SO IT CAN BE
RIGHT***** JAVA
Here are the instructions and then the code in a sec.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.java
Player.java
GameService.j.
C# Program. Create a Windows application that has the functionality .pdffathimalinks
C# Program. Create a Windows application that has the functionality of a calculator and works
with integral values. Allow the user to select buttons representing numeric values. If the user
attempts to divide by zero, throw and handle an exception.
Solution
below is the code from the windows application in visual studio:
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SimpleCalculator
{
public partial class frmCalculator : Form
{
string operand1 = string.Empty;
string operand2 = string.Empty;
string result;
char operation;
public frmCalculator()
{
InitializeComponent();
}
private void frmCalculator_Load(object sender, EventArgs e)
{
btnOne.Click += new EventHandler(btn_Click);
btnTwo.Click += new EventHandler(btn_Click);
btnThree.Click += new EventHandler(btn_Click);
btnFour.Click += new EventHandler(btn_Click);
btnFive.Click += new EventHandler(btn_Click);
btnSix.Click += new EventHandler(btn_Click);
btnSeven.Click += new EventHandler(btn_Click);
btnEight.Click += new EventHandler(btn_Click);
btnNine.Click += new EventHandler(btn_Click);
btnZero.Click += new EventHandler(btn_Click);
btnDot.Click += new EventHandler(btn_Click);
}
void btn_Click(object sender, EventArgs e)
{
try
{
Button btn = sender as Button;
switch (btn.Name)
{
case \"btnOne\":
txtInput.Text += \"1\";
break;
case \"btnTwo\":
txtInput.Text += \"2\";
break;
case \"btnThree\":
txtInput.Text += \"3\";
break;
case \"btnFour\":
txtInput.Text += \"4\";
break;
case \"btnFive\":
txtInput.Text += \"5\";
break;
case \"btnSix\":
txtInput.Text += \"6\";
break;
case \"btnSeven\":
txtInput.Text += \"7\";
break;
case \"btnEight\":
txtInput.Text += \"8\";
break;
case \"btnNine\":
txtInput.Text += \"9\";
break;
case \"btnZero\":
txtInput.Text += \"0\";
break;
case \"btnDot\":
if(!txtInput.Text.Contains(\".\"))
txtInput.Text += \".\";
break;
}
}
catch(Exception ex)
{
MessageBox.Show(\"Sorry for the inconvenience, Unexpected error occured. Details:
\" +
ex.Message);
}
}
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case \'1\':
case \'2\':
case \'3\':
case \'4\':
case \'5\':
case \'6\':
case \'7\':
case \'8\':
case \'9\':
case \'0\':
//case \'+\':
//case \'-\':
//case \'*\':
//case \'/\':
//case \'.\':
break;
default:
e.Handled = true;
MessageBox.Show(\"Only numbers, +, -, ., *, / are allowed\");
break;
}
}
private void txtInput_TextChanged(object sender, EventArgs e)
{
}
private void btnPlus_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'+\';
txtInput.Text = string.Empty;
}
private void btnMinus_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'-\';
txtInput.Text = string.Empty;
}
private void btnMulitply_Click(object sender, EventArgs e)
{
operand1 = txtInput.Text;
operation = \'*\';
txtInput.Text = string.Empty;
}
private void btnDivide_Click.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
I really need some help if I have this right so far. Please Resub.pdfaggarwalshoppe14
I really need some help if I have this right so far. ***Please Resubmit the revsised and updated
Code with Comments added explaining please. RIGHT***** JAVA
Here are the instructions and then the code in a sec.
Part II. Java Application: Use the code you submitted in Project One Milestone to continue
developing the game application in this project. Be sure to correct errors and incorporate
feedback before submitting Project One.
Please note: The starter code for this project was provided in the Project One Milestone. If you
have not completed the Project One Milestone, you will not be penalized in this assignment, but
you will have additional steps to complete to ensure you meet all the components of Project One.
Review the class files provided and complete the following tasks to create a functional game
application that meets your clients requirements. You will submit the completed game
application code for review.
Begin by reviewing the base Entity class. It contains the attributes id and name, implying that all
entities in the application will have an identifier and name.
Software Design Patterns: Review the GameService class. Notice the static variables holding the
next identifier to be assigned for game id, team id, and player id.
Referring back to Project One Milestone, be sure that you use the singleton pattern to adapt an
ordinary class, so only one instance of the GameService class can exist in memory at any given
time. This can be accomplished by creating unique identifiers for each instance of a game, team,
or player.
Your client has requested that the game and team names be unique to allow users to check
whether a name is in use when choosing a team name. Referring back to the Project One
Milestone, be sure that you use the iterator pattern to complete the addGame() and getGame()
methods.
Create a base class called Entity. The Entity class must hold the common attributes and
behaviors (as shown in the UML diagram provided in the Supporting Materials section below).
Refactor the Game class to inherit from this new Entity class.
Complete the code for the Player and Team classes. Each class must derive from the Entity class,
as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to
adding the new instance. Use the iterator pattern in the addTeam() and addPlayer() methods.
Functionality and Best Practices
Once you are finished coding, use the main() method provided in the ProgramDriver class to run
and test the game application to ensure it is functioning properly.
Be sure your code demonstrates industry standard best practices to enhance the readability of
your code, including appropriate naming conventions and in-line comments that describe the
functionality.
Here is my answer that I need a little improvement on its code since I am having trouble making
it right.
Here I am attaching code for these Files:
Entity.java
Game.java
Team.java
Player.java
GameService.java
P.
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docxraju957290
MIS 4310-01 Final Take Home Exam (100 points)
DUE: Thursday, December 14th, 2017 by 11:59 PM
Use the code provided on Blackboard as your template. Fill in your own code where
prompted. When finished, upload to Blackboard a file called “treasure_hunt.java”. Change
the block comment to include your own name. This is an individual assignment! Code that
you write that you cannot explain will result in an automatic zero.
Create a Java application that simulates a treasure hunt with a 2D array. Your output
should match the output below with similar input. Do NOT alter the code provided. Fill
in code in the SEVEN (7) locations under each comment // YOUR CODE HERE.
Sample Output:
import java.util.Random;
import java.util.Scanner;
/*
* First Last
* MIS 4310 Fall 2017
* FINAL TAKE HOME EXAM
*/
public class treasure_hunt {
public static void main(String[] args) {
boolean found = false; // is true if the treasure is found
int dug = 0; // holds the number of times user digs
Random gen = new Random(9);
Scanner scan = new Scanner(System.in);
int locationRow; // stores the row where the treasure is
int locationCol; // stores the column where the treasure is
/*
* Generates a String array that looks like
* undug grass when printed to represent the backyard.
*/
String[][] backyard = new String[5][5];
for (int row = 0; row < backyard.length; row++) {
for (int col = 0; col < backyard[row].length; col++) {
backyard[row][col] = "^";
System.out.print(backyard[row][col] + " ");
} // end inner loop
System.out.println();
} // end outer loop
/*
* Generate a random number for both the row and column
* location of the treasure. Store the results in
* locationRow and locationCol, respectively.
* The random numbers should be within the array dimensions.
*/
//**************************
// YOUR CODE HERE (1 OF 7)
//**************************
/*
* A while loop that runs as long as the treasure
* is not found.
*/
while (found == false) {
/*
* Declare two integer variables, guessRow and guessCol
* and set them both to -1.
* Increment the variable dug to represent a dig.
*/
//**************************
// YOUR CODE HERE (2 OF 7)
//**************************
/*
* Ask the user which row they want to dig.
* Use a while loop to validate the input.
* Run the while loop as long as the guessRow
* value is outside the bounds of the array.
*/
//**************************
// YOUR CODE HERE (3 OF 7)
//**************************
/*
* Ask the user which column they want to dig.
* Use a while loop to validate the input.
* Run the while loop as long as the guessCol
* value is outside the bounds of the array.
*/
...
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
Please read the comment ins code
ExpressionTree.java
----------------------------------
/**
* This is the class for Expression Tree.
* Used to create Expression Tree and Evaluate it
*/
/**
* Following logic is used to construct a Tree
* Here we use stack for Preparing Tree
* Loop through given Expression String
* If Character is Operand , Create node and push to stack
* If Character is Operator then
* 1)Create Node for Operator
* 2)Pop 2 nodes from Stack and Made
* OpretorNode--> left == first node pop
* OpretorNode--> right == second node pop
* At the end of creation of Expression Tree, Stack have only one node , which is root of
Expression tree
*/
/** Class ExpressionTree **/
class ExpressionTree
{
/** class TreeNode
* Stored Character ==> Digit(0..9) or a Operator +,-,*,/
* Left Node and Right Node
*
* **/
class TreeNode
{
char data;
TreeNode left, right;
/** constructor **/
public TreeNode(char data)
{
this.data = data;
this.left = null;
this.right = null;
}
}
/** class StackNode **/
class StackNode
{
TreeNode treeNode;
StackNode next;
/** constructor **/
public StackNode(TreeNode treeNode)
{
this.treeNode = treeNode;
next = null;
}
}
private static StackNode top;
/** constructor
* Constructor takes input string like \"+-+7*935*82*625\"
* Input should be in Prefix notation
* **/
public ExpressionTree(String expression)
{
top = null;
//Call Method for prepare expression tree
buildTree(expression);
}
/** function to clear tree **/
public void clear()
{
top = null;
}
/** function to push a node **/
private void push(TreeNode ptr)
{
if (top == null)
top = new StackNode(ptr);
else
{
StackNode nptr = new StackNode(ptr);
nptr.next = top;
top = nptr;
}
}
/** function to pop a node
* When it find operator pop 2 elements from Stack
*
* **/
private TreeNode pop()
{
if (top == null)
throw new RuntimeException(\"Underflow\");
else
{
TreeNode ptr = top.treeNode;
top = top.next;
return ptr;
}
}
/** function to get top node **/
private TreeNode peek()
{
return top.treeNode;
}
/** function to insert character **/
private void insert(char val)
{
try
{
//If Operand , Create node and push to Stack
if (isDigit(val))
{
TreeNode nptr = new TreeNode(val);
push(nptr);
}
//If Operator , Create node and popup 2 elements and make them its right and left
else if (isOperator(val))
{
TreeNode nptr = new TreeNode(val);
nptr.left = pop();
nptr.right = pop();
push(nptr);
}
}
catch (Exception e)
{
System.out.println(\"Invalid Expression\");
}
}
/** function to check if digit **/
private boolean isDigit(char ch)
{
return ch >= \'0\' && ch <= \'9\';
}
/** function to check if operator **/
private boolean isOperator(char ch)
{
return ch == \'+\' || ch == \'-\' || ch == \'*\' || ch == \'/\';
}
/** function to convert character to digit **/
private int toDigit(char ch)
{
return ch - \'0\';
}
/** function to build tree from input */
public void buildTree(String eqn)
{
for (int i = eqn.length() - 1; i >= 0; i--)
insert(eqn.charAt(i));
}
/** function to evaluate tree */
public dou.
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
Create a C# application
You are to create a class object called “Employee” which included eight private variables:
firstN
lastN
dNum
wage: holds how much the person makes per hour
weekHrsWkd: holds how many total hours the person worked each week.
regHrsAmt: initialize to a fixed amount of 40 using constructor.
regPay
otPay
After going over the regular hours, the employee gets 1.5x the wage for each additional hour
worked.
Methods:
constructor
properties
CalcPay(): Calculate the regular pay and overtime pay.
Create an “EmployeeDemo” class. In the main function, the program should ask the user the
number of employee in the company and create a 2-dimensional dynamic array (number of
employee by 4 weeks). Then, the program should ask user to enter each employee’s information
and the amount of hours they worked weekly.
The program shows a menu with employee name for user to choose which employee to display
the following information:
How much the person totally made
How much of paycheck is regular pay
How much of paycheck is overtime pay
Solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Employee
{
public enum EmployeeType {GROUPA, GROUPB, GROUPC, GROUPD};
public struct EmployeeSalaryInfo
{
public float hourlyWage;
public int monthlyHours;
public float baseSalary;
public int numSales;
public EmployeeSalaryInfo( EmployeeType eme)
{
this.hourlyWage = 0;
this.monthlyHours = 0;
this.baseSalary = 0;
this.numSales = 0;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(\"Welcome to the Employee System\");
EmployeeArray empArray = new EmployeeArray();
int continueRunning = 1;
do
Console.WriteLine();
Console.WriteLine(\"Please Enter Your Choice:\");
Console.WriteLine(\"1=Enter new employee\");
Console.WriteLine(\"2=Update existing employee\");
Console.WriteLine(\"3=Delete employee\");
Console.WriteLine(\"4=Print employee list\");
Console.WriteLine(\"Any other number to Exit\");
int userChoice = int.Parse(Console.ReadLine());
Console.WriteLine();
switch (userChoice)
{
case 1:
Employee emp = CreateNewWorker(); //Asking for employee information by
creating a new employee.
if (!(empArray.Contains(emp))) //Checking to see that employee does not
exist
empArray.Add(emp); //If the employee does not exist in the list then
we can add it.
else
Console.WriteLine(\"Can not add new worker. This worker already exists\");
break;
case 2: //If user wishes to edit an employee
EditEmployee(empArray);
break;
case 3:
DeleteEmployee(empArray); //if user wishes to delete an employee from
the list
break;
case 4:
empArray.Print();
break;
default:
continueRunning = 0; //If user has chosen to exit the system.
break;
}
} while (continueRunning == 1); //Checking to see if to continue running
the system
}
static Employee CreateNewWorker() //Method for creating a
new employee.
{
Employee emp; //A new employee consists of
the basic information which is
Console.WriteLine(\"Enter first name.
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD
OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE
PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE
MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS.
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below
Read gamescore.txt to initialize the Linked list in sorted order by score.
Ask the user to add or remove users to update the sorted linked list.
Display “Name exist” when add an exist name to the list.
Display “Name does not exist” when remove a name not on the list.
List.java File:
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List
{
/**
* Remove all contents from the list, so it is once again empty. Client is
* responsible for reclaiming storage used by the list elements.
*/
public void clear();
/**
* Insert an element at the current location. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be inserted.
*/
public void insert(E item);
/**
* Append an element at the end of the list. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be appended.
*/
public void append(E item);
/**
* Remove and return the current element.
*
* @return The element that was removed.
*/
public E remove();
/** Set the current position to the start of the list */
public void moveToStart();
/** Set the current position to the end of the list */
public void moveToEnd();
/**
* Move the current position one step left. No change if already at
* beginning.
*/
public void prev();
/**
* Move the current position one step right. No change if already at end.
*/
public void next();
/** @return The number of elements in the list. */
public int length();
/** @return The position of the current element. */
public int currPos();
/**
* Set current position.
*
* @param pos
* The position to make current.
*/
public void moveToPos(int pos);
/** @return The current element. */
public E getValue();
}
LList.java File:
/**
* Source code example for \"A Practical Introduction to Data Structures and
* Algorithm Analysis, 3rd Edition (Java)\" by Clifford A. Shaffer Copyright
* 2008-2011 by Clifford A. Shaffer
*/
// Doubly linked list implementation
class LList implements List
{
private DLink head; // Pointer to list header
private DLink tail; // Pointer to last element in list
protected DLink curr; // Pointer ahead of current element
int cnt; // Size of list
// Constructors
LList(int size)
{
th.
week3_src/DoWhileLoopFactorial.javaweek3_src/DoWhileLoopFactorial.javapackage edu.drexel.ct290;
import java.util.Scanner;
publicclassDoWhileLoopFactorial{
/**
* A factorial is calculated by multiplying a number by
* every integer less than itself except zero. For example the
* factorial of 4, written 4!, is 4*3*2*1 = 24.
*/
publiclong calculateFactorial(int number){
// declare and initialize a variable to hold the answer
long factorial=number;
// the do while loop will run the block of code between the braces
// as long as the condition in the while statement is true.
// The different between this and the while loop is that
// here, the code will always execute at least once.
do{
// the print statement can help debug errors is in the code
System.out.println("Fact: "+ factorial +", number: "+ number);
// calculate the next factor
factorial = factorial *(number-1);
// decrement the number so that the next iteration of the loop
// will have the correct value to multiply
number--;
}
while( number >1);
// return the answer to the caller.
return factorial;
}
publicstaticvoid main(String[] args){
// Get the user input
Scanner reader =newScanner(System.in);
System.out.print("What number do you want a factorial for: ");
int number = reader.nextInt();
// Create a DoWhileLoopFactorial class
DoWhileLoopFactorial loopFactorial =newDoWhileLoopFactorial();
// call calculateFactorial to compute the answer
long factorial = loopFactorial.calculateFactorial( number );
// Show the user the answer
System.out.println("The answer is: "+ factorial);
}
}
__MACOSX/week3_src/._DoWhileLoopFactorial.java
week3_src/ForLoopFactorial.javaweek3_src/ForLoopFactorial.javapackage edu.drexel.ct290;
import java.util.Scanner;
publicclassForLoopFactorial{
/**
* A factorial is calculated by multiplying a number by
* every integer less than itself except zero. For example the
* factorial of 4, written 4!, is 4*3*2*1 = 24.
*/
publiclong calculateFactorial(int number){
// declare and initialize a variable to hold the answer
long factorial = number;
// The for loop has three parts:
// initialization: int i=number;
// condition: i>1;
// increment/decrement: i--;
// The variable in the initialization is called the control variable
// The initialization happens once when the loop starts.
// The loop will execute as long as the condition is true.
// The decrement will happen automatically after each iteration.
for(int i=number; i>1; i--){
// the print statement can help debug errors is in the code
System.out.println("Fact: "+ factorial +", i: "+ i);
// calculate the next factor
factorial = factorial *(i-1);
}
// return the answer to the caller.
return factorial;
}
publicstaticvoid main(String[] args){
// Get the user input
Scanner reader =newScanner(System.in);
System.out.print("What number do you want a factorial for: ");
int number = reader.nextInt();
// Create a WhileLoopFactoria.
SeriesTester/.classpath
SeriesTester/.project
SeriesTester
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
SeriesTester/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
SeriesTester/bin/seriesTester/FibonacciSequence.classpackage seriesTester;
publicsynchronizedclass FibonacciSequence {
private int firstNumber;
private int secondNumber;
public void FibonacciSequence();
public boolean validStartNumbers(int, int);
public void printSequence(int);
public void printSequence(int, int, int);
private void setSecondNumber(int);
private void setFirstNumber(int);
public void resetSequence();
}
SeriesTester/bin/seriesTester/PowerSeries.classpackage seriesTester;
publicsynchronizedclass PowerSeries {
private math2 myMath;
private double value_of_x;
private double number_of_terms;
public void PowerSeries();
public void setX(double);
public void setNumOfTerms(double);
public double run_eTo_xSeries();
public double run_sin_Of_xSeries();
public double run_PowerSeries();
}
SeriesTester/bin/seriesTester/SeriesTester.classpackage seriesTester;
publicsynchronizedclass SeriesTester {
privatestatic java.util.Scanner keyboard;
privatestatic FibonacciSequence myFibonacci;
privatestatic PowerSeries myPower;
static void <clinit>();
public void SeriesTester();
publicstatic void main(String[]);
privatestatic void powerSeries();
privatestatic void fibonociiSeries();
privatestatic String selectSerries();
}
SeriesTester/bin/seriesTester/math2.classpackage seriesTester;
publicsynchronizedclass math2 {
public void math2();
public int factorial(int);
}
SeriesTester/src/seriesTester/SeriesTester.javaSeriesTester/src/seriesTester/SeriesTester.javapackage seriesTester;
import java.util.Scanner;
publicclassSeriesTester
{
/**
* @param args
* Author Larry R Shannon This is the demo/testing program for the
* Fibonacci/Power series project. The algorithm for the demo part of
* this project is as follows: Variables needed: State Variables:
* Scanner keyboard is used to read data from the input data buffer.
* (the keyboard) FibonacciSequence myFibonacci is the class object
* that contains the data and methods needed to explore the Fi.
Similar to ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf (20)
Which one of the following is NOT a social trend that is currently af.pdffathimahardwareelect
Which one of the following is NOT a social trend that is currently affecting how individuals
behave and set up priorities? A. Growth in the use of mobile devices O B. Passage &t; the
Affordable Care Act (Obamacare) O C. Aging of the population O D. The increasing diversity of
the workforce E. Increased participation in social networks Click to select your answer
Solution
Ans
The increased diversity of workforce. It affects individual behavior but not his priorities.
Which of the following is normally a major activity of materials man.pdffathimahardwareelect
Which of the following is normally a major activity of materials management? I. Manufacturing
planning and control II. Physical supply/distribution a. both I and II b. neither I nor II c. I only d.
II only
Solution
material management is focus on all the activities of manufacturing planning, control, supply of
the goods and distribution of the goods.
so, option A is correct.
What is the role of civil society in promoting democracySolutio.pdffathimahardwareelect
What is the role of civil society in promoting democracy?
Solution
1) Civil society can limit and control the power of the state. A country must need a way to keep
the power of political leaders in check or control.
2) Civil society exposes the corrupt officials and government bodies. Even though the anti-
corruption laws exists but for them to function effectively active participation of civil society is
required.
3) NGOs can educate people about their fundamental rights given by the constitution.
4) Civil societies can be training platforms for future leader.
5) Civil societies also play a vital role in the monitoring the conduct of elections. They make sure
that the POLL takes place without any manipulations of the machines at polling station..
What mechanism causes plant ion-uptake to acidify soilSolution.pdffathimahardwareelect
What mechanism causes plant ion-uptake to acidify soil?
Solution
Answer=
The mechanisms that causes plant ion uptake to acidify soil=
soil acidification is a natural process in high rainfall environments
major nutrient fertilizers such as nitrogen is major nutrient affecting soil pH
there are 3 mechanisms
1] root interception = it is physical contact resulted by root growth
2] Mass flow= involves the transport of nutrients to the root as a result of transpiration
3] diffusion movement= caused by differences in concentration
nutrients are taken up by roots which dominant in nutrition or by leaves is only additional in
nutrition.
using the knowledge about experiments that are related to plant g.pdffathimahardwareelect
using the knowledge about experiments that are related to plant growth including those done by
fritz went to answer the questions above a) What was the HYPOTHESIS that went wanted to
answer (2ptsy? b) How did Went test his hypothesis (Pictures are ok as long as there are words
explaining the picture) (4ptsy! c) What was the final RESULT of Went\'s experiment (2pts)?
Solution
Cholodony- Went model decribes tropism in emerging shoots of monocotyledons, including the
tendencies of the shoot to grow towards light ( phototropism) and the roots towards downward
position ( Gravitropism).
In both the cases the directional growth is considered to be due to asymmetrical distribution of
Auxin, a plant hormone.
The rate of growth depends on the concentration of the auxin and both gravity and unidirectional
light effect the movement of auxin.
Basic Model: cholodony and went proposed that auxin is synthesised in the coleoptile tip which
senses light and sends the auxin down the shady side of the coleoptile.
Later experiments showed that auxin moved from a source along a horizontal coleoptile section,
concentrating along the bottom of the section and causing the shoot to bend upward.
The model was later extended to Gravitropism of roots where auxin was thought to inhibit rather
than stimulate growth and to accumulate in the lower side of the root section causing the root to
bend.
Result of Cholodony Went Model: Both phototropism and gravitropism is due to the
asymmetrical distribution of hormone auxin. The rate of growth is dependent on concentration of
auxin and both gravity and unidirectional light effect the movement of auxin..
True or False Justify your answer.The concept of flooding is alwa.pdffathimahardwareelect
True or False? Justify your answer.
The concept of flooding is always a bad idea for routing IP packets.
Solution
TRUE.
Because flooding can be costly in terms of wasted bandwidth. While a message may only
have one destination it has to be sent to every host. In the case of a ping flood or a denial of
service attack, it can be harmful to the reliability of a computer network. Furthermore messages
can become duplicated in the network further increasing the load on the networks bandwidth as
well as requiring an increase in processing complexity to disregard duplicate messages.
Duplicate packets may circulate forever, unless certain precautions are taken:.
True or False. If H is a subgroup of the group G then H is one of it.pdffathimahardwareelect
True or False. If H is a subgroup of the group G then H is one of its cosets in G. Every
subgroup of a group G is normal. If |H|
Solution
a) True as He=H where e is identity element.
b) False, only the subgroup N satistfying the property gng^-1 in N for every n in N and g in G(
group) are normal.
but if group is abelian then every subgroup is normal.
c) True, as K contain more elements than H it has more subgroups.
d) False, For two distinct cosest identity elements belongs to only one cosets because distinct
cosets for set of equivalance classes.
e) yes for each positive integer n we have group for that number.
f) false, because it is only true only if G has order of prime power (sylow thm).
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdffathimahardwareelect
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED
HELP FIXING THIS CODE?
THIS IS THE PROBLEM
Write a program that allows the user to enter two positive integers and outputs their sum. Sounds
simple? Here\'s the catch: The numbers may be any size! They may be way too large to store in a
single variable. You may not assume any particular maximum number of digits.
HERE IS THE CODE
#include
#include
struct node /* Linked list node*/
{
int data;
struct node* next;
};
struct node *newNode(int data) /* Function to create a new node with giving the data*/
{
struct node *new_node = (struct node *) malloc(sizeof(struct node));
new_node->data = data;
new_node->next = NULL;
return new_node;
}
void push(struct node** head_ref, int new_data) /* Function to insert a node at the beginning of
the Doubly Linked List*/
{
struct node* new_node = newNode(new_data); /*allocate a node*/
new_node->next = (*head_ref); /* link the old list off to the new node*/
(*head_ref) = new_node; /*move the head to point to the new node*/
}
/* Adding the contents of two linked lists and return the head node of resultant list*/
struct node* addTwoLists (struct node* first, struct node* second)
{
struct node* res = NULL; /* res is head node of the resultant list*/
struct node *temp, *prev = NULL;
int carry = 0, sum;
while (first != NULL || second != NULL) /*while both the lists exists*/
{
/* Calculate value of next digit in resultant list.
// The next digit is sum of following things
// (i) Carry
// (ii) Next digit of first list (if there is a next digit)
// (ii) Next digit of second list (if there is a next digit)*/
sum = carry + (first? first->data: 0) + (second? second->data: 0);
carry = (sum >= 10)? 1 : 0; /* update carry for next calulation*/
sum = sum % 10; /*update sum if it is greater than 10*/
temp = newNode(sum); /*Create a new node with sum as data*/
if(res == NULL) /*if this is the first node then set it as head of the resultant list*/
res = temp;
else /* If this is not the first node then connect it to the rest.*/
prev->next = temp;
prev = temp; /* Set prev for next insertion*/
if (first) first = first->next; /* Move first pointers to next node*/
if (second) second = second->next; /*Move second pointer to the next node*/
}
if (carry > 0)
temp->next = newNode(carry);
return res; /* return head of the resultant list*/
}
void printList(struct node *node) /* function to print a linked list*/
{
while(node != NULL)
{
printf(\"%d \", node->data);
node = node->next;
}
printf(\"\ \");
}
int main(void) /* program to test above function*/
{
struct node* res = NULL;
struct node* first = NULL;
struct node* second = NULL;
printf(\"Enter first positive integer: \");
scanf(\"%d\",&first);
printList(first);
printf(\"Enter second positive integer: \");
scanf(\"%d\",&second);
printList(second);
/*Add the two lists and see result*/
res = addTwoLists(first, second);
printf(\"Sum is: %d\");
printList(res);
return 0;
}
Solution
#include
#include
typedef struct Node
{
int da.
Immunizations that the elderly need to receive on a yearly basis inc.pdffathimahardwareelect
Immunizations that the elderly need to receive on a yearly basis include the following: (Select all
that apply.)
a. Pneumonia vaccine
b. Influenza vaccine
c. Tetanus vaccine
d. Polio vaccine
e. Hepatitis B vaccine
Solution
a. Pneumonia vaccine
b. Influenza vaccine
c. Tetanus vaccine
Mostly elderly people above 60 years of age get seasonal flu or influenza infection. And also get
Pneumonia due to effect of cold season.The immune system becomes weak incompatible to bear
seasonal changes. Also, they need to get tetanus vaccine in form of Tdap vaccine that protects
against Tetanus, Diptheria, and Pertussis diseases..
Question 11 Scarcity means O people need to use marginal analysis to .pdffathimahardwareelect
Question 11 Scarcity means O people need to use marginal analysis to make choices O options
are restricted O opportunity costs arise O all of the above
Solution
Answer is All the above.
Explanation:
Scarcity means limited available resources and allocation of these resources need to be made
based on marginal analysis of various options available. These options are restricted based on
limited resources. The resources put in one option must have an opportunity cost of foregoing the
next best option..
Question 2 Sba Do you know something about the Statement Of Financ.pdffathimahardwareelect
Question 2 Sba: \"Do you know something about the Statement Of Financial Position (SOFP)?
Don: \"What\'s that?\" Sba: The SOFP is actually not a part of the double entry system. Don:
\"Are you sure? But when I close the ledgers, its balances are all shown in the SOFP Sha: \"Yup,
I am pretty sure. Did you forget that the SOFP doesn\'t have closing balances?\" Don: \"Oh
yeah.... Required: Based on the above conversation, discuss on the implications in which the
Statement Of Financial Position (SOFP) not being part of the double entry system. (3 marks)
Solution
EXPLANATION --- First of all lets discuss what is Statement of Financial position?? It is
basically a statement showing the financial position of an individual or any entity or organisation
at the end of end at a particular date. It is none other than BALANCE SHEET. It is made up of 3
things -- LIABILITIES , ASSETS and EQUITY.
It helps stakeholders and users of financial statements to assess the financial soundness of an
entity in terms of liquidity risk, financial risk, credit risk and business risk.
Now lets discuss whether statement of financial position is part of double entry system or not ??
No , it is a part of double entry system as it shows the total balances of assets, liabilities and
equity at a particular given date. As double entry system affects two ledgers at a single
transaction so balance sheet is also dependent upon double entry book system.Therefore, Yes
Balance Sheet (accounts) are also a part of the double entry system, however it is not mandatory
to have a balance sheet account in each and every double entry transaction..
Question 1. give the CC++ code that defines an empty 5 element arra.pdffathimahardwareelect
Question 1. give the C/C++ code that defines an empty 5 element array called dataarray and a
pointer called datapointer which is assigned to the first memory address of the data array.
Solution
Answer:
#include
using namespace std;
int main()
{
int dataarray[5];
int *datapointer = &dataarray[0];
return 0;
}.
List and explain all the components of company culture.Jackson, S..pdffathimahardwareelect
List and explain all the components of company culture.
Jackson, S. E., Schuler, R. S., & Werner, S. (2012). Managing Human Resources (11th ed.).
Cengage Learning
Solution
Building a company culture of engaged employees takes years and requires consistent execution.
I boiled down our culture strategy into 10 essential components I call the \"10 Cs of Culture.\"
1. Core Values
I used to be very cynical about \"core values.\" I thought these were just mottos written on
plaques hanging on the wall. But when we implemented our values strategy at Beryl about 10
years ago, I began to see how they guided everyday decision-making and how employees
referenced them in meetings. I came to realize they are essential guideposts when developed,
communicated, and executed in a consistent manner. Values are those behaviors that will never
change no matter how the company changes. Today, our values are not only painted on the
walls, but also discussed from the first day an employee joins Beryl. We start every big meeting
with a conversation about values and tell stories about how our coworkers live by those values
on a daily basis.
2. Camaraderie
Camaraderie is about having fun. It\'s about getting to know colleagues not just as colleagues,
but what they\'re like outside the office. To do that, Beryl hosts dress-up days, parties, games,
and events all the time. We have annual traditions like family day, the Gong show, March
Madness, the fall festival, and a holiday party. We include not only employees, but also their
families. We publish a bi-monthly full-color magazine called Beryl Life that is sent to the homes
of co-workers. Kids of our employees compete to design the t-shirt for our annual family day
and families even participate in our talent show
3. Celebrations
You can\'t underestimate the importance of recognizing your team. While it may be important
for your people to hear from the CEO, it also feels great for them to hear from peers. At Beryl,
we developed a program we call PRIDE (Peers Recognizing Individual Deeds of
Excellence). This allows coworkers to recognize others for living up to Beryl\'s core values. We
also have quarterly contests for people who have received PRIDE certificates. We go out of our
way to celebrate personal successes too, like baby showers, sports accomplishments, or
educational milestones.
4. Community
Part of the fabric of a successful company culture is connecting with and giving back to the local
community. Even though Beryl is a national company serving national customers, we have
dedicated countless hours to community service in Bedford, Texas (where Beryl is based) to help
those in need. This not only helps the organization\'s Beryl support, but brings great pride to
staffers.
5. Communication
At Beryl, I encourage formal and informal communication consistently and at all levels of the
company. I hold quarterly Town Hall meetings, which includes six meetings over two days. This
is a challenge since Beryl is a 24-hour .
Please write 5-6 setences about each emotional intelligence capabili.pdffathimahardwareelect
Please write 5-6 setences about each emotional intelligence capabilities (with the traits). This is a
part of my paper. Please help!
Self-Awareness – with the traits: Emotional Self-Awareness, Accurate Self-Assessment, and
Self-Confidence.
Self-Management – with the traits: Self-Control, Trustworthiness, Conscientiousness,
Adaptability, Achievement Orientation, and Initiative.
Social Awareness – with the traits: Empathy, Organizational Awareness, and Service Orientation
Social Skill – with the traits: Visionary Leadership, Influence, Developing Others,
Communication, Change Catalyst, Conflict Management, Building Bonds and
Teamwork/Collaboration.
Solution
Self-Awareness
Self awareness is the quality to understand oneself through various self assessment activities,
awareness can be defined as the knowledge to distinguish between right and wrong, therefore
self awareness generally means the individual ability to make one\'s self aware about any aspect.
Self confidence plays a huge role in this context because self confidence helps a person to
believe in himself and do the right things to be successful it is closely related with self awareness
because if a person is not aware of certain things then it is difficult to apply the learning\'s and
knowledge. Self awareness is influenced by the emotional qualities that each and every
individual possess and it is very much necessary for the emotional growth of the individual as
well.
Self Management
It can be stated that no individual can be successful without the quality of self management
because each and every individual needs to manage himself in various points of life without
which success will not be achieved. Control is the most important aspect here because the
individual should possess proper control of all the emotions be it anything and he should also be
well aware of his actions too. The individual needs to possess the quality of adaptation because
without proper adaptation it will be difficult for him to cope with various situations that will
come his way. Achievement should not impact much and change the person because no
achievement is too big or too small he should learn from the mistakes and the achievements
which will help him grow as a human being.
Social Awareness
There are some social responsibilities that each and every individual should be responsible
enough to execute because without that the individual becomes socially inactive. The individual
should judge each and every situation by keeping himself in the situation of the other person or
group and empathize the situation while taking a decision or stand. As conveyed there are some
social responsibilities as well as organizational responsibilities that each and every organization
expects from its employees and the individual should abide by them. This is a very important
trait that individuals should possess in order to be socially active and aware.
Social Skill
A soft skill which an employer is always looking in his employee b.
Please help me find my errors. I am lost as I know what the problem.pdffathimahardwareelect
Please help me find my error/s. I am lost as I know what the problem is but not sure how to fix it.
Problem: Exception in thread \"main\" java.lang.Error: Unresolved compilation problems:
The method getNumberofdays() is undefined for the type Year
The method getNumberofdays() is undefined for the type LeapYear
at UseYear.main(UseYear.java:11)
UseYear.java
public class UseYear
{
public static void main(String args[])
{
//Initializing class
Year year = new Year();
//Calling method to display days
year.getNumberofdays();
//Initializing class
LeapYear leapyear = new LeapYear();
//Calling to display days
leapyear.getNumberofdays();
}
}
LeapYear.java
public class LeapYear extends Year
{
//Constructor for LeapYear class
public LeapYear()
{
setNumberofdays(366);
}
}
Year.java
public class Year
{
//Variable
int numberofdays;
public void getNumberofdays
{
System.out.println(numberofdays);
}
//Method to set the value
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
//Constructor for Year class
public Year()
{
setNumberofdays(365);
}
}
UseYear2.java
public class UseYear2
{
public static void main(String args[])
{
int day = 2, month = 3;
//Initializing class
Year2 year = new Year2();
//Initializing class
LeapYear2 leapyear = new LeapYear2();
//Display days elapsed
System.out.println(\"Days elapsed in a Year: \" + year.daysElapsed(day, month));
System.out.println(\"Days elapsed in a Leap Year: \" + leapyear.daysElapsed(day, month));
}
}
LeapYear2.java
public class LeapYear extends Year
{
//Constructor for class
public LeapYear2()
{
//Setting number of days
setNumberofdays(366);
}
//Method to get end value
public int daysElapsed(int day, int month)
{
int temp = 0;
for (int i = 1; i < month;i++);
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
{
temp += 31;
}
else if (i == 4 || i == 6 || i == 9 || i == 11)
{
temp += 30;
}
else if (i == 2)
{
temp += 29;
}
}
temp += day;
return temp;
}
}
Year2.java
public class Year2
{
int numberofdays;
public void getNumberofdays()
{
System .out.println(numberofdays);
}
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
public Year2()
{
setNumberofdays(365);
}
public int daysElapsed(int day, int month)
{
int temp = 0;
for (int i = 1; i < month;i++);
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
{
temp += 31;
}
else if (i == 4 || i == 6 || i == 9 || i == 11)
{
temp += 30;
}
else if (i == 2)
{
temp += 28;
}
}
temp += day;
return temp;
}
}
Solution
HI, I have fixed all error.
Please let me know in case of any issue.
######## Year.java #######
public class Year
{
//Variable
private int numberofdays;
//Constructor for Year class
public Year()
{
setNumberofdays(365);
}
public int getNumberofdays()
{
return numberofdays;
}
//Method to set the value
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
}
################## LeapYear.java ############
public class LeapYear extends Y.
Negligence and intentional torts are subject to civil litigation as .pdffathimahardwareelect
Negligence and intentional torts are subject to civil litigation as opposed to criminal litigation.
However, should a person who commits a civil tort like battery, also be prosecuted criminally?
Some famous examples of criminal defendants who were prosecuted civilly as well as criminally
are OJ Simpson and Bernard Madoff. How was it possible for OJ Simpson to be acquitted in the
criminal case but found liable for wrongful death in the civil case?
Solution
Intentional tort such as battery is two dimensional in nature. If they are not severe they can be
treated as civil wrong and are handled as a civil lawsuit for demand of compensation as monetary
damages.
However, if they are severe and are result of the criminal intent of the person they will be
considered a crime and can lead to prosecution by the state under criminal laws. In the case of
the OJ Simpson he was acquitted because the plaintiff failed to prove the presence of death by
criminal intent. But he was responsible for the death as even if there is no criminal intent one can
be found responsible under various civil theories such as negligence etc..
Incuded within the major CPI basket groups are various government-cha.pdffathimahardwareelect
Incuded within the major CPI basket groups are various government-charged user fees, such as
water a charges, auto registration fees, and vehicle tolls. True False
Solution
The CPI measures the change in the price level of basket of goods from one year to another year.
It includes the price changes in the basket of consumer goods and services. The CPI does not
include the fees and charges for the services.
ANS: FALSE..
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdffathimahardwareelect
Identify major groupings within the Lophotrochozoa and Ecdy gg g sozoa ; describe
distinguishing features among groups, where on Earth these organisms are typically found, and
how they make a living
Solution
Lophotrochozoa are a group or taxon of protostome animals. The taxon consists of 2 groups-
trochozoans and lophophorata. Trochozoans are characterized by the development of mouth
before anus in the embryo.They are worm like and produce trochophore larvae - larvae that have
2 bands of cilia around their middle. Lophophorata, on the other hand, are grouped by the
presence of lophophore characterized by a fan of ciliated tentacles surrounding their mouths.
These animals exhibit radial cleavage.
Lophotrochophora includes the following phyla
1. Phylum Ectoprocta:
These are mostly marine coelomates that use lophophore for feesing. They secrete and live in
zoecium (chitinous chamber).
2. Phylum platyhelminthes
These are mostly parasitic acoelomates. Some may live as scavengers or commensals. The are
flat and ribbon-shaped. They have an incomplete gut, no circulatory system, and a simple
nervous system. Their excretory system has small tubules lined with ciliated flame cells. They
are hermaphrodites.
3. Phylum Rotifera
These are small aquatic pseudocoelomate animals. They are mostly free living and a few are
paraitic. They have a ciliated food gathering organ at the tip of the head known as corona. They
have jaws in the pharynx and their digestive system has separate mouth and anus. They have
rudimentary circulatory system and they have separate sexes.
4. Phylum Annelida
They are segmented coelomates with a closed circulatory system. Their excretory system
includes nephrida. They have a digestive system with separate mouth and anus. Gas exchange is
through skin.They have setae. They are found in both terrestrial and aquatic habitats. They can
be parasites, carnivores, predators or scavengers.
5. Phylum Nemertea
They are partially coelomate and partially acoelomate animals. They are free living and possess
proboscis - a long muscular tube covered by a sheath to capture prey. They have a complete
digestive system, a simple nervous system, and a closed circulatory system.
6. Phylum Phoronida:
They are coelomate and marine. They use lophophore for feeding. They have a U-shaped gut and
they secrete and live in a chitinous tube.
7. Phylum Brachipoda:
They are characterized by the presence of 2 calcified shells.
Ecdysozoa also belons to the group of protostome animals characterized by a three layered
cuticle which is periodically molted,a process known as ecdysis. They lack locomotary cilia.
They produce amoeboid sperm. Their embryos donot undergo spiral cleavage unlike other
protostomes.
The group includes
Phylum arthropoda
The phylum includes invertebrate animals with an exoskeleton. They have jointed limbs and
their cuticle is made of chitin. They are segmented with an open circulatory system and a ladder-
like nervous system They are found in both a.
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdffathimahardwareelect
How many grams of solid NaCN have to be added to 1.4 L of water to dissolve 0.11 mol of
Fe(OH)3in the form of Fe(CN)63−? (For simplicity, ignore the reaction of CN−ion with
water.)
Solution
3 moles of NaCN dissolve 1 mole of Fe(OH)3
3*.11 = .33 moles NaCN will dissolve .11 mole of Fe(OH)3
wt reqd. = 0.33*(23+12+14)
w = 16.17 g.
How does Warhol add to the semiotic statement of the readymadeS.pdffathimahardwareelect
How does Warhol add to the semiotic statement of the readymade?
Solution
ABSTRACT -
This paper \"breaks out of the box\" by discussing the work of the artist Andy Warhol as a form
of consumer research. The paper asserts that Warhol’s career- successful artist, experimental
filmmaker, prolific writer and diarist, celebrity-offers insights into consumer culture that
reinforces, expands, and illuminates aspects of traditional consumer research. Through
illustrations, criticism, and interpretation, five specific areas of consumer research that Warhol’s
work might contribute to are introduced: brand equity; clothing, fashion and beauty; imagery;
packaging; and self-concept. This project joins recent efforts by consumer researchers to include
humanities based methods such as literary criticism and semiotics into the consumer researcher’s
toolbox.
I love America and these are some comments on it. The image is a statement of the symbols of
the harsh impersonal products and brash materialistic objects on which America is built today. It
is a projection of everything that can be bought and sold, the practical but important symbols that
sustain us.
- Warhol 1985, p. 78
Humanities based research has changed the parameters of consumer research. Groundbreaking
applications of semiotics (Mick 1986), literary theory (Stern 1988; 1989) postmodernism (Firat
and Venkatesh 1995), history (Jones and Monieson 1990), visual studies (Scott 1994)to- name a
few-have broadened the consumer researcher’s alette, adding useful tools to an interdisciplinary
paintbox. Belk proposes that art offers a useful medium to study consumption-citing literature,
comics, painting, photography, etc., as valuable records of materialism and non-traditional
sources of data for consumer researchers (Belk, 1986). Art and science do differ in their
methods, biases, and purposes, Belk insists, but there is much more overlap than is usually
thought. He concludes by suggesting that uses of art in research \"are attempts to draw on art as
data for evidence to validate a point or to provide a thicker, richer description\" (Belk, 1986, p.
27).
This paper proposes that Andy Warhol-through his worldwide success as an artist, his choice of
subject matter, his public statements, and his marketing techniques-may offer insights into
several issues of consumer research as an additional way of learning about consumer behavior
(Belk, Wallendorf, and Sherry 1989; Hudson and Ozanne 1988; Sherry 1991). Through a turn to
the tools of art criticism and art history, Warhol’s \"contributions\" to our understanding of
consumer behavior are placed within the frame of consumer research. Warhol, while not trained
in experimental methods, nonetheless offers unique insights into consumer behavior through his
success as an artist who focused on the mass produced world of brand names, fame, and
consumption.
In his career as a commercial illustrator, artist, filmmaker, and author, Warhol produced a
voluminous output of ma.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
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.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
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.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
How libraries can support authors with open access requirements for UKRI fund...
ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf
1. ArrayListOfObjects
Assignment 4:
100 points
due Thurs, Feb 23rd.
Adapt your ArrayOfPokemon code from assignment 2 to use the new Pokemon objects.
When adding a Pokemon, instead of making the user enter all the information, make a menu for
them to pick from the nine (or more) implemented species: (Bulbasaur, Ivysaur, Venusaur,
Charmander, Charmaleon, Charizard, Squirtle, Wartortle, Blastoise).The only thing the user must
choose is the species of Pokemon and if it gets a name.
If they want a name, then the program should ask them to enter one.
Then call the constructor for the chosen Pokemon. For example: Pokemon p = new Bulbasaur();
or Pokemon p = new Squirtle(sName);
Change the Array from assignment 2 to a Java API ArrayList.
For examples on using an ArrayList, see the uploaded sample code ArrayListDemo.java and
slide 40 of ICS211_Lecture09_ListsAndContainers.pdf on Laulima -> Resources -> Week 5.
Also see the Java API website for ArrayList for available methods.
The allowed number of stored Pokemon should still be limited to 6. Don't let the ArrayList keep
growing though it can!
Assignment 2 code is here,Please help me change it to match Assignment 4's requirement.
This is the Pokemon.java code.import java.util.*; //scannerpublic class PokeArray{static final int
SIZE = 6;public static void main(String[] args){Scanner userIn = new
Scanner(System.in);String inString = new String("");boolean endLoop = false;Pokemon[]
arrPoke = new Pokemon[SIZE];int nextIndex = 0; //points to index for next insert//loop until
stopping condition is givenwhile(endLoop != true){//menu textSystem.out.println("Please enter
the number of your choice:");System.out.println("1. Add a Pokemon");System.out.println("2.
Print all Pokemon");System.out.println("0. Exit the program");System.out.print("What
would you like to do? ");//read in from user as a String -- much less errors can happen!inString
= userIn.nextLine();//take off any spaces on the stringinString = inString.trim();//just switch on
the String no need to convert to intswitch(inString){case "0": endLoop =
true;System.out.println("Good bye!");break;case "1": //do stuff to make a new
PokemonarrPoke[nextIndex] = PokeArray.makePokemon();nextIndex = (nextIndex + 1)%
SIZE; //makes value run from 0-5 alwaysbreak;case "2": //print out all the
PokemonPokeArray.printArray(arrPoke);break;default: //not a valid menu
entrySystem.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2
");break;}}}//close main method/** makePokemon asks user for data for a new Pokemon
2. object and instantiates it** @return a Pokemon to insert into the array*/public static Pokemon
makePokemon(){Scanner userIn = new Scanner(System.in);Pokemon newPoke;//Data for new
Pokemon constructorString inName = new String("");String inNick = new String("");String
inNum = new String("");//have to convert to an intString inType1 = new String("");String
inType2 = new String("");int iNum = 0;boolean dataGood = false;//keep taking input until user
enters valid inputwhile(dataGood == false){//this can be used later when Pokemon exception is
made tootry{System.out.println("Enter the Pokemon's name:");inName =
userIn.nextLine();inName = inName.trim();System.out.println("Enter a nickname, or just enter
if none:");inNick = userIn.nextLine();inNick = inNick.trim();System.out.println("Enter the
Pokemon's number:");inNum = userIn.nextLine();inNum = inNum.trim();iNum =
Integer.parseInt(inNum); //parse into an intSystem.out.println("Enter the Pokemon's
type:");inType1 = userIn.nextLine();inType1 = inType1.trim();System.out.println("Enter the
Pokemon's second type, if none just enter:");inType2 = userIn.nextLine();inType2 =
inType2.trim();dataGood = true;}catch(NumberFormatException nfe){System.out.println("You
didn't enter a valid number, try again");}}if(inNick.length() > 0){//call 5 parameter
constructornewPoke = new Pokemon(inName, inNick, iNum, inType1, inType2);}else{//call
constructor without nicknamenewPoke = new Pokemon(inName, iNum, inType1,
inType2);}return newPoke;}/** printArray prints array of Pokemon* @param pArray an array
of Pokemon Objects*/public static void printArray(Pokemon[] pArray){for(int i = 0; i < SIZE;
i++){if(pArray[i] != null){//don't print the indicies that are not
filledSystem.out.println("Pokemon "+ i + ": ");
System.out.println(pArray[i].toString());}}}//end printArray method}
Solution
/*The main difference between Assignment2 and Assignment4 is implementation of ArrayList
and Inheritance*/
import java.util.*; //scanner
public class PokeArray{
static final int SIZE = 6;
public static void main(String[] args){
3. Scanner userIn = new Scanner(System.in);
String inString = new String("");
boolean endLoop = false;
ArrayList pokeList=new ArrayList(SIZE);
//loop until stopping condition is given
while(endLoop != true){
//menu text
System.out.println("Please enter the number of your choice:");
System.out.println("1. Add a Pokemon");
System.out.println("2. Print all Pokemon");
System.out.println("0. Exit the program");
System.out.print("What would you like to do? ");
//read in from user as a String -- much less errors can happen!
inString = userIn.nextLine();
//take off any spaces on the string
inString = inString.trim();
//just switch on the String no need to convert to int
switch(inString){
case "0": endLoop = true;
System.out.println("Good bye!");
break;
case "1": //do stuff to make a new Pokemon
pokeList.add(PokeArray.makePokemon());
break;
case "2": //print out all the Pokemon
PokeArray.printArray(pokeList);
break;
default: //not a valid menu entry
System.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2 ");
break;
4. }
}
}//close main method
/*
* makePokemon asks user for data for a new Pokemon object and instantiates it
*
* @return a Pokemon to insert into the array
*/
public static Pokemon makePokemon(){
Scanner userIn = new Scanner(System.in);
Pokemon newPoke;
//Data for new Pokemon constructor
String inName = new String("");
String inNick = new String("");
int iNum = 0;
boolean dataGood = false;
//keep taking input until user enters valid input
//this can be used later when Pokemon exception is made too
try{
System.out.println("Enter the Pokemon's name:");
inName = userIn.nextLine();
inName = inName.trim();
System.out.println("Enter a nickname, or just enter if none:");
inNick = userIn.nextLine();
inNick = inNick.trim();
if(inNick.length() > 0){//call 5 parameter constructor
if(inName=="Bulbasaur")
newPoke = new Bulbasaur(inNick);
else if(inName=="Ivysaur")
newPoke = new Ivysaur(inNick);
else if(inName=="Venusaur")
5. newPoke = new Venusaur(inNick);
else if(inName=="Charmander")
newPoke = new Charmander(inNick);
else if(inName=="Charmaleon")
newPoke = new Charmaleon(inNick);
else if(inName=="Charizard")
newPoke = new Charizard(inNick);
else if(inName=="Squirtle")
newPoke = new Squirtle(inNick);
else if(inName=="Wartotle")
newPoke = new Wartotle(inNick);
else if(inName=="Blastoise")
newPoke = new Blastoise(inNick);
else throw new Exception ();
}
else{//call constructor without nickname
if(inName=="Bulbasaur")
newPoke = new Bulbasaur();
else if(inName=="Ivysaur")
newPoke = new Ivysaur();
else if(inName=="Venusaur")
newPoke = new Venusaur();
else if(inName=="Charmander")
newPoke = new Charmander();
else if(inName=="Charmaleon")
newPoke = new Charmaleon();
else if(inName=="Charizard")
newPoke = new Charizard();
else if(inName=="Squirtle")
newPoke = new Squirtle();
else if(inName=="Wartotle")
newPoke = new Wartotle();
else if(inName=="Blastoise")
newPoke = new Blastoise();
else throw new Exception ();
}
6. }catch(Exception e){
System.out.println("Pokemon not found!! ");
}
return newPoke;
}
/*
* printArray prints array of Pokemon
* @param pArray an array of Pokemon Objects
*/
public static void printArray(ArrayList pArray){
Iterator itr=pArray.iterator();
//traversing elements of ArrayList object
while(itr.hasNext()){
Pokemon st=(Pokemon)itr.next();
System.out.println(st.toString());
}
}//end printArray method
}
Pokemon.java
import java.util.Random;
import java.text.*; //imports decimal format
public class Pokemon{
/** instance variables **/
/* the actual kind of Pokemon */
private String name;
/* optional user-defined name */
private String nickName;
/* official Pokemon number for Pokedex */
private int number;
7. /* required type of Pokemon */
private String type1;
/* optional second type */
private String type2;
/* interally calculated Hit Points */
private int HP;
/* internally calculated Combat Power */
private int CP;
/* main constructor with nickName and two types
* @param name official Pokemon name for this kind of Pokemon
* @param nickName user-given name or name if none
* @param number official Pokedex number for this Pokemon
* @param type1 the Pokemon type
* @param type2 second type if Pokemon has one, otherwise empty string
*/
public Pokemon(String name, String nickName, int number, String type1, String type2){
this.name = name;
this.nickName = nickName;
this.type1 = type1;
this.type2 = type2;
this.number = number;
initHPCP();
}
/* constructor with no nickname and two types
* calls other constructor with nickName set to name
* @param name the official Pokemon name for this kind of Pokemon
* @param number official Pokedex number for this Pokemon
* @param type1 the Pokemon type
* @param type2 second type if Pokemon has one
*/
/*
8. * private method for initializing HP and CP from constructors
*/
private void initHPCP(){
//generate random numbers
Random randGen = new Random();
int newHP;
int newCP;
double multiplier;
double CPrangeMin = 1.00;
double CPrangeMax = 3.00;
newHP = randGen.nextInt(141) + 10; //integer between 10 and 150 inclusive
this.HP = newHP;
multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble();
this.CP = (int)(newHP*multiplier);
}
/*
* Returns Pokemon information as a formatted String
* @return String representing Pokemon object data
*/
public String toString( ){
DecimalFormat df = new DecimalFormat("000");
String s="";
s = "Name: " + this.name + " ";
if(this.name.compareTo(this.nickName) != 0){
s = s + "Nickname: " + this.nickName + " ";
}
s = s + "Number: " + df.format(this.number) + " ";
s = s + "Type: " + this.type1;
if(this.type2.length() > 0){
s = s + " | " + this.type2;
}
s = s+ " ";
9. s = s + "HP: " + this.HP + " ";
s = s + "CP: " + this.CP + " ";
return s;
}
/*
* updates a Pokemon's HP and CP
* CP only updated if random multiplier increases it
* otherwise it stays the same
*/
public void powerUp(){
Random randGen = new Random();
int newHP;
double multiplier;
double CPrangeMin = 1.00;
double CPrangeMax = 3.00;
this.HP = (int)(this.HP + 1.15 + (0.2*this.HP));//set HP using formula
multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble();
if((this.HP * multiplier) > this.CP){
this.CP = (int)(this.HP * multiplier);
}
}
/** Get Methods **/
public String getName(){
return this.name;
}
public String getNickName(){
return this.nickName;
}
public String getType1(){
return this.type1;
}
10. public String getType2(){
return this.type2;
}
public int getNumber(){
return this.number;
}
public int getHP(){
return this.HP;
}
public int getCP() {
return this.CP;
}
/*
* only Nickname is user-settable
* @param String the new nickname for this Pokemon
*/
public void setNickName(String newNickName){
this.nickName = newNickName;
}
}
public class Bulbasaur extends Pokemon{
Bulbasaur()
{
super("Bulbasaur","Bulbasaur",1,"Grass","");
}
Bulbasaur(String sName)
{
super("Bulbasaur",sName,1,"Grass","");
}
}
public class Ivysaur extends Pokemon{
Ivysaur()
{
super("Ivysaur","Ivysaur",2,"Grass","");
}
11. Ivysaur(String sName)
{
super("Ivysaur",sName,2,"Grass","");
}
}
public class Venusaur extends Pokemon{
Venusaur()
{
super("Venusaur","Venusaur",3,"Grass","");
}
Venusaur(String sName)
{
super("Venusaur",sName,3,"Grass","");
}
}
public class Charmander extends Pokemon{
Charmander()
{
super("Charmander","Charmander",4,"Fire","");
}
Charmander(String sName)
{
super("Charmander",sName,4,"Fire","");
}
}
public class Charmaleon extends Pokemon{
Charmaleon()
{
super("Charmaleon","Charmaleon",5,"Fire","");
}
Charmaleon(String sName)
{
super("Charmaleon",sName,5,"Fire","");
}
}
public class Charizard extends Pokemon{
12. Charizard()
{
super("Charizard","Charizard",6,"Fire","");
}
Charizard(String sName)
{
super("Charizard",sName,6,"Fire","");
}
}
public class Squirtle extends Pokemon{
Squirtle()
{
super("Squirtle","Squirtle",7,"Water","");
}
Squirtle(String sName)
{
super("Squirtle",sName,7,"Water","");
}
}
public class Wartotle extends Pokemon{
Wartotle()
{
super("Wartotle","Wartotle",8,"Water","");
}
Wartotle(String sName)
{
super("Wartotle",sName,8,"Water","");
}
}
public class Blastoise extends Pokemon{
Blastoise()
{
super("Blastoise","Blastoise",9,"Water","");
}
Blastoise(String sName)
{