java question: \"Fill the add statement area\"
Project is to work with stacks.
package p2;
public class Coordinate {
public int x;
public int y;
public Coordinate( int x, int y ) {
this.x = x;
this.y = y;
}
public String toString() {
return \"(\" + this.x + \",\" + this.y + \")\";
}
@Override
public boolean equals( Object object ) {
if( object == null ) {
return false;
}
if( ! Coordinate.class.isAssignableFrom( object.getClass() )) {
return false;
}
final Coordinate other = (Coordinate) object;
return this.x == other.x && this.y == other.y;
}
}
package p2;
public class Coordinate {
public int x;
public int y;
public Coordinate( int x, int y ) {
this.x = x;
this.y = y;
}
public String toString() {
return \"(\" + this.x + \",\" + this.y + \")\";
}
@Override
public boolean equals( Object object ) {
if( object == null ) {
return false;
}
if( ! Coordinate.class.isAssignableFrom( object.getClass() )) {
return false;
}
final Coordinate other = (Coordinate) object;
return this.x == other.x && this.y == other.y;
}
}
package p2;
import java.util.Vector;
public class Maze {
private char[][] maze;
private int height;
private int width;
/**
* Create a new Maze of the specified height and width, initializing every
* location as empty, with a \' \'.
**/
public Maze( int width, int height ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as blocked,
* marking it with a \'X\'
**/
public void setBlocked( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as having been visited,
* marking it with a \'*\'
**/
public void setVisited( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as part of the path solution,
* marking it with a \'.\'
**/
public void setPath( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Returns the character at the locatio specified by the Coordinate
**/
public char at( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Returns a Coordinate array containing all Coordinates that are clear around
* the specified coordinate.
**/
public Coordinate[] clearAround( Coordinate coord ) {
Vector vector = new Vector();
// ADD STATEMENTS HERE
// Look at each of the locations around the specified Coordinate, and add it
// to the vector if it is clear (i.e. a space)
return vector.toArray( new Coordinate[0] );
}
/**
* Returns a Coordinate that provides the entrance location in this maze.
**/
public Coordinate start() {
return new Coordinate( 0, 1 );
}
/**
* Returns a Coordinate that provides the exit location from this maze.
**/
public Coordinate end() {
// ADD STATEMENTS HERE
}
/**
* The toString() method is responsible for creating a String representation
* of the Maze. See the project specification for sample output. Note that
* the String representation adds numbers across the top and side of the Maze
* to show the Coordinates of each cell in the maze.
**/
public String toString() {
StringBuilder buffer =.
Java Question help needed In the program Fill the Add statements.pdfkamdinrossihoungma74
Item 8 Singly ionized (one electron removed) atoms are accelerated and then passed through a
velocity selector consisting of perpendicular electric and magnetic fields. The electric field is 158
V/m and the magnetic field is 3.13 Times 10^2 T. The ions next enter a uniform magnetic field
of magnitude 1.73 Times 10^-2 T that is oriented perpendicular to their velocity. How fast are
the ions moving when they emerge from the velocity selector? If the radius of the path of the
ions in the second magnetic field is 17.4 cm, what is their mass?
Solution
A)
In Velocity selector Electric field & Magnetic field forces on ions are equal & opposite ,this is
because it allows ions with a particular velocity only passes undeflected.
so we can say,
Bqv = Eq
B:magnetic field density
E:Electric field
v:velocity at which the ions remains undeflected.
v=E/B
v = 158V/m / 3.13*10-2 T
=> v = 4.78*103 m/s
B)
as it enteres next in uniform magnetic field of value B=1.73*10-2 T
Work done in uniform magnetic field is zero.It only changes the direction.So B provides
centripetal force for the ions while changing direction in circular path of radius r=17.4cm.
Bqv = mv²/r
m = Bqr / v = (1.73*10-2T)(1.6*10-19C)(0.174m) / (4.78*103m/s)
=>m = 1*10-25 kg.
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdfaarokyaaqua
How to fix this error:
Exception in thread "main" q. Exit
java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "action" is null
at AddressBook.main(AddressBook.java:23)
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
System.out.print("Add another entry? (y/n): ");
String answer = scanner.nextLine().toLowerCase();
moreEntries = answer.equals("y") || answer.equals("yes");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
OTHER FILES THAT GO WITH THIS
public class Node {
private String name;
private String address;
private Node next;
Node() {
// add here ..
}
Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
this.next = null;
}
public String getKey() {
// add here ..
return this.name;
}
public void setKey(String name) {
// add here ..
this.name = name;
}
public String getValue() {
// add here ..
return this.address;
}
public void setValue(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public void setNext(Node next) {
// add here ..
this.next = next;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
publi.
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfpnaran46
How do I fix this error "
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.hashCode()"
because "action" is null
at AddressBook.main(AddressBook.java:25)"
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
System.out.print("Add another entry? (y/n): ");
String answer = scanner.nextLine().toLowerCase();
moreEntries = answer.equals("y") || answer.equals("yes");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
Other files that go with it
public class Node {
private String name;
private String address;
private Node next;
Node() {
// add here ..
}
Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
this.next = null;
}
public String getKey() {
// add here ..
return this.name;
}
public void setKey(String name) {
// add here ..
this.name = name;
}
public String getValue() {
// add here ..
return this.address;
}
public void setValue(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public void setNext(Node next) {
// add here ..
this.next = next;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
public Node.
operating system linux,ubuntu,Mac Geometri.pdfaquadreammail
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = \"white\";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println(\"Area of a1 is \" + a1.findArea());
System.out.println(\"Perimeter of a1 is \" + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? \"a1 and its clone a2 have the same area\"
: \"a1 and its clone a2 have different areas\";
System.out.println(\"Compare a1 and its clone a2:\ \\t \" + result);
System.out.println(\"Hashcode of a1: \" + a1.hashCode());
System.out.println(\"Hashcode of a2: \" + a2.hashCode());
System.out.println(\"Displaying a1: \" + a1);
System.out.println(\"Displaying a2: \" + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
.
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
Creat Shape classes from scratch DETAILS You will create 3 shape classes (Circle, Rectangle,
Triangle) that all inherit from a single abstract class called AbstractShape which implements
Shape (also created by you). You are also responsible for creating the driver class
\"Assignment7.java\" (program that tests your classes and described on page 3) which does the
following reads input data from a file instantiates various objects of the three shapes based on the
input data stores each in a LinkedList outputs this list to an output file sorts a \"copy\" of this
LinkedList of objects outputs the sorted version of the list to the output file outputs the original
list to the output file This driver program also needs to \"ignore errors in the input file that breach
the specified input format as described in the Assianment7,java details (see page 3 1. Shape.java
This is an interface that has 2 abstract methods, and passes the responsibility of implementing the
compareTo method to the class that implements Shape (you may note, nomally Comparable is
\"implemented\" by a class. However, an interface cannot implement because interfaces can only
contain abstract methods. That said, an interface can only extend other interfaces and the
responsibility of actually \"implementing\" the abstract method(s) of the super class interface is
passed on to the sub-classes) public interface Shape extends Comparable public double
calculateAreal) Il This abstract method is implemented at the concrete level public Shape
copyShape); Il also implemented at the concrete level 2. AbstractShape.java public abstract class
AbstractShape implements Shape This class should contain an instance field to store the name of
each obiect. The constructor which sets this field should receive the name and a number to be
concatenated to the name and then stored in the name field Recall, when the super class has a
parameterized constructor, the sub-classes will need to call it AND the sub- classes will need to
also provide a constructor without parameters This abstract class will implement the compareTo
method passed on from the Shape interface and will pass on the responsibility of implementing
calculateArea to the extending sub-classes (compare To will use the calculateArea method when
comparing 2 Shape objects). Along with compare To, one more concrete method should be
included. The following will be used by the sub-classes\' toString method: public String
getName) II Simply returns the name field data
Solution
in7.txt
4.4
2.5 3
8.1 3.0 5.0
2.5 3 4
2.5
tuesday
-7
1.0
3 three
3 -9
3 5
1.0
Assignment7.java
import java.io.*;
import java.util.*;
public class Assignment7 {
/**
* This is the test driver class that will include main.
* This program MUST read a file named in7.txt and
* generate an output file named out7.txt. The in7.txt
* file must be created by you based on formatting
* described shortly.
*
* @param theArgs
*/
public static void main(String[] theArgs) {
List myList = new Arra.
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
New folder/jsjf/ArrayStack.classpackage jsjf;
publicsynchronizedclass ArrayStack implements StackADT {
privatestaticfinal int DEFAULT_CAPACITY = 100;
private int top;
private Object[] stack;
public void ArrayStack();
public void ArrayStack(int);
public void push(Object);
private void expandCapacity();
public Object pop() throws exceptions.EmptyCollectionException;
public Object peek() throws exceptions.EmptyCollectionException;
public int size();
public boolean isEmpty();
public String toString();
}
New folder/jsjf/ArrayStack.javaNew folder/jsjf/ArrayStack.javapackage jsjf;
import jsjf.exceptions.*;
import java.util.Arrays;
// -------------------------------------------------------
// Author: Yifu Wu
// Date: 03/10/16
// Source Name: ArrayStack<T>
// Due date: 03/10/16
// Description:
/**
* An array implementation of a stack in which the bottom of the
* stack is fixed at index 0.
*
* @author Java Foundations
* @version 4.0
*/
publicclassArrayStack<T>implementsStackADT<T>
{
privatefinalstaticint DEFAULT_CAPACITY =100;
privateint top;
private T[] stack;
/**
* Creates an empty stack using the default capacity.
*/
publicArrayStack()
{
this(DEFAULT_CAPACITY);
}
/**
* Creates an empty stack using the specified capacity.
* @param initialCapacity the initial size of the array
*/
publicArrayStack(int initialCapacity)
{
top =0;
stack =(T[])(newObject[initialCapacity]);
}
/**
* Adds the specified element to the top of this stack, expanding
* the capacity of the array if necessary.
* @param element generic element to be pushed onto stack
*/
publicvoid push(T element)
{
if(size()== stack.length)
expandCapacity();
stack[top]= element;
top++;
}
/**
* Creates a new array to store the contents of this stack with
* twice the capacity of the old one.
*/
privatevoid expandCapacity()
{
//stack = Arrays.copyOf(stack, stack.length * 2);
System.out.println("Expanding stack capacity\n");
T[] temp =(T[])(newObject[2*top]);
for(int i=0; i< top; i++)
temp[i]= stack[i];
stack = temp;
}
/**
* Removes the element at the top of this stack and returns a
* reference to it.
* @return element removed from top of stack
* @throws EmptyCollectionException if stack is empty
*/
public T pop()throwsEmptyCollectionException
{
if(isEmpty())
thrownewEmptyCollectionException("stack");
top--;
T result = stack[top];
stack[top]=null;
return result;
}
/**
* Returns a reference to the element at the top of this stack.
* The element is not removed from the stack.
* @return element on top of stack
* @throws EmptyCollectionException if stack is empty
*/
public T peek()throwsEmptyCollectionException
{
if(isEmpty())
thrownewEmptyCollectionException("stack");
return stack[top-1];
}
/**
* Returns the number of elements in ...
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
Java Question help needed In the program Fill the Add statements.pdfkamdinrossihoungma74
Item 8 Singly ionized (one electron removed) atoms are accelerated and then passed through a
velocity selector consisting of perpendicular electric and magnetic fields. The electric field is 158
V/m and the magnetic field is 3.13 Times 10^2 T. The ions next enter a uniform magnetic field
of magnitude 1.73 Times 10^-2 T that is oriented perpendicular to their velocity. How fast are
the ions moving when they emerge from the velocity selector? If the radius of the path of the
ions in the second magnetic field is 17.4 cm, what is their mass?
Solution
A)
In Velocity selector Electric field & Magnetic field forces on ions are equal & opposite ,this is
because it allows ions with a particular velocity only passes undeflected.
so we can say,
Bqv = Eq
B:magnetic field density
E:Electric field
v:velocity at which the ions remains undeflected.
v=E/B
v = 158V/m / 3.13*10-2 T
=> v = 4.78*103 m/s
B)
as it enteres next in uniform magnetic field of value B=1.73*10-2 T
Work done in uniform magnetic field is zero.It only changes the direction.So B provides
centripetal force for the ions while changing direction in circular path of radius r=17.4cm.
Bqv = mv²/r
m = Bqr / v = (1.73*10-2T)(1.6*10-19C)(0.174m) / (4.78*103m/s)
=>m = 1*10-25 kg.
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdfaarokyaaqua
How to fix this error:
Exception in thread "main" q. Exit
java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "action" is null
at AddressBook.main(AddressBook.java:23)
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
System.out.print("Add another entry? (y/n): ");
String answer = scanner.nextLine().toLowerCase();
moreEntries = answer.equals("y") || answer.equals("yes");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
OTHER FILES THAT GO WITH THIS
public class Node {
private String name;
private String address;
private Node next;
Node() {
// add here ..
}
Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
this.next = null;
}
public String getKey() {
// add here ..
return this.name;
}
public void setKey(String name) {
// add here ..
this.name = name;
}
public String getValue() {
// add here ..
return this.address;
}
public void setValue(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public void setNext(Node next) {
// add here ..
this.next = next;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
publi.
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfpnaran46
How do I fix this error "
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.hashCode()"
because "action" is null
at AddressBook.main(AddressBook.java:25)"
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
System.out.print("Add another entry? (y/n): ");
String answer = scanner.nextLine().toLowerCase();
moreEntries = answer.equals("y") || answer.equals("yes");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
Other files that go with it
public class Node {
private String name;
private String address;
private Node next;
Node() {
// add here ..
}
Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
this.next = null;
}
public String getKey() {
// add here ..
return this.name;
}
public void setKey(String name) {
// add here ..
this.name = name;
}
public String getValue() {
// add here ..
return this.address;
}
public void setValue(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public void setNext(Node next) {
// add here ..
this.next = next;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
public Node.
operating system linux,ubuntu,Mac Geometri.pdfaquadreammail
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = \"white\";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println(\"Area of a1 is \" + a1.findArea());
System.out.println(\"Perimeter of a1 is \" + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? \"a1 and its clone a2 have the same area\"
: \"a1 and its clone a2 have different areas\";
System.out.println(\"Compare a1 and its clone a2:\ \\t \" + result);
System.out.println(\"Hashcode of a1: \" + a1.hashCode());
System.out.println(\"Hashcode of a2: \" + a2.hashCode());
System.out.println(\"Displaying a1: \" + a1);
System.out.println(\"Displaying a2: \" + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
.
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
Creat Shape classes from scratch DETAILS You will create 3 shape classes (Circle, Rectangle,
Triangle) that all inherit from a single abstract class called AbstractShape which implements
Shape (also created by you). You are also responsible for creating the driver class
\"Assignment7.java\" (program that tests your classes and described on page 3) which does the
following reads input data from a file instantiates various objects of the three shapes based on the
input data stores each in a LinkedList outputs this list to an output file sorts a \"copy\" of this
LinkedList of objects outputs the sorted version of the list to the output file outputs the original
list to the output file This driver program also needs to \"ignore errors in the input file that breach
the specified input format as described in the Assianment7,java details (see page 3 1. Shape.java
This is an interface that has 2 abstract methods, and passes the responsibility of implementing the
compareTo method to the class that implements Shape (you may note, nomally Comparable is
\"implemented\" by a class. However, an interface cannot implement because interfaces can only
contain abstract methods. That said, an interface can only extend other interfaces and the
responsibility of actually \"implementing\" the abstract method(s) of the super class interface is
passed on to the sub-classes) public interface Shape extends Comparable public double
calculateAreal) Il This abstract method is implemented at the concrete level public Shape
copyShape); Il also implemented at the concrete level 2. AbstractShape.java public abstract class
AbstractShape implements Shape This class should contain an instance field to store the name of
each obiect. The constructor which sets this field should receive the name and a number to be
concatenated to the name and then stored in the name field Recall, when the super class has a
parameterized constructor, the sub-classes will need to call it AND the sub- classes will need to
also provide a constructor without parameters This abstract class will implement the compareTo
method passed on from the Shape interface and will pass on the responsibility of implementing
calculateArea to the extending sub-classes (compare To will use the calculateArea method when
comparing 2 Shape objects). Along with compare To, one more concrete method should be
included. The following will be used by the sub-classes\' toString method: public String
getName) II Simply returns the name field data
Solution
in7.txt
4.4
2.5 3
8.1 3.0 5.0
2.5 3 4
2.5
tuesday
-7
1.0
3 three
3 -9
3 5
1.0
Assignment7.java
import java.io.*;
import java.util.*;
public class Assignment7 {
/**
* This is the test driver class that will include main.
* This program MUST read a file named in7.txt and
* generate an output file named out7.txt. The in7.txt
* file must be created by you based on formatting
* described shortly.
*
* @param theArgs
*/
public static void main(String[] theArgs) {
List myList = new Arra.
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
New folder/jsjf/ArrayStack.classpackage jsjf;
publicsynchronizedclass ArrayStack implements StackADT {
privatestaticfinal int DEFAULT_CAPACITY = 100;
private int top;
private Object[] stack;
public void ArrayStack();
public void ArrayStack(int);
public void push(Object);
private void expandCapacity();
public Object pop() throws exceptions.EmptyCollectionException;
public Object peek() throws exceptions.EmptyCollectionException;
public int size();
public boolean isEmpty();
public String toString();
}
New folder/jsjf/ArrayStack.javaNew folder/jsjf/ArrayStack.javapackage jsjf;
import jsjf.exceptions.*;
import java.util.Arrays;
// -------------------------------------------------------
// Author: Yifu Wu
// Date: 03/10/16
// Source Name: ArrayStack<T>
// Due date: 03/10/16
// Description:
/**
* An array implementation of a stack in which the bottom of the
* stack is fixed at index 0.
*
* @author Java Foundations
* @version 4.0
*/
publicclassArrayStack<T>implementsStackADT<T>
{
privatefinalstaticint DEFAULT_CAPACITY =100;
privateint top;
private T[] stack;
/**
* Creates an empty stack using the default capacity.
*/
publicArrayStack()
{
this(DEFAULT_CAPACITY);
}
/**
* Creates an empty stack using the specified capacity.
* @param initialCapacity the initial size of the array
*/
publicArrayStack(int initialCapacity)
{
top =0;
stack =(T[])(newObject[initialCapacity]);
}
/**
* Adds the specified element to the top of this stack, expanding
* the capacity of the array if necessary.
* @param element generic element to be pushed onto stack
*/
publicvoid push(T element)
{
if(size()== stack.length)
expandCapacity();
stack[top]= element;
top++;
}
/**
* Creates a new array to store the contents of this stack with
* twice the capacity of the old one.
*/
privatevoid expandCapacity()
{
//stack = Arrays.copyOf(stack, stack.length * 2);
System.out.println("Expanding stack capacity\n");
T[] temp =(T[])(newObject[2*top]);
for(int i=0; i< top; i++)
temp[i]= stack[i];
stack = temp;
}
/**
* Removes the element at the top of this stack and returns a
* reference to it.
* @return element removed from top of stack
* @throws EmptyCollectionException if stack is empty
*/
public T pop()throwsEmptyCollectionException
{
if(isEmpty())
thrownewEmptyCollectionException("stack");
top--;
T result = stack[top];
stack[top]=null;
return result;
}
/**
* Returns a reference to the element at the top of this stack.
* The element is not removed from the stack.
* @return element on top of stack
* @throws EmptyCollectionException if stack is empty
*/
public T peek()throwsEmptyCollectionException
{
if(isEmpty())
thrownewEmptyCollectionException("stack");
return stack[top-1];
}
/**
* Returns the number of elements in ...
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
There is something wrong with my program-- (once I do a for view all t.pdfaashienterprisesuk
There is something wrong with my program.. (once I do a for view all this is the outcome in the
console...(carnea:Name: carnea, Address: 30 repeated..) why is this?
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
action = scanner.nextLine();
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
public class Node {
private String name;
private String address;
private Node next;
public Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
}
public String getName() {
// add here ..
return this.name;
}
public void setName(String name) {
// add here ..
this.name = name;
}
public String getAddress() {
// add here ..
return this.address;
}
public void setAddress(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public String toString() {
return "Name: "+ name +", Address:" +address;
}
public void setNext(Node node) {
// add here ..
this.next = next;
}
public void setAddress (Object newValue) {
this.address = address;
}
public void setName(Object newValue) {
this.name = name;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
public Node get.
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfmail931892
How do I fix it in LinkedList.java?
this is what i did
LabProgram.java
LinkedList.java:
/**
* Defines a doubly-linked list class
* @author
* @author
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
if (iterator != null){
return iterator.data;
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
if(iterator != null){
Node newNode = new Node(data);
newNode.next = iterator.next;
iterator.next = newNode;
if (iterator == first){
first = newNode;
}
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/
public void remov.
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
Using NetBeans
Implement a queue named QueueLL using a Linked List (same as we did for the stack). This
implementation must be used in all the following problems.
Implement a queue QueueST using a stack (use StackLL).
Test your implementations in the main with examples.
Solution
Answer:-
import java.util.*;
/* Class Node */
class Node
{
protected int data;
protected Node link;
/* Constructor */
public Node()
{
link = null;
data = 0;
}
/* Constructor */
public Node(int d,Node n)
{
data = d;
link = n;
}
/* Function to set link to next Node */
public void setLink(Node n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(int d)
{
data = d;
}
/* Function to get link to next node */
public Node getLink()
{
return link;
}
/* Function to get data from current Node */
public int getData()
{
return data;
}
}
/* Class linkedQueue */
class linkedQueue
{
protected Node front, rear;
public int size;
/* Constructor */
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
/* Function to check if queue is empty */
public boolean isEmpty()
{
return front == null;
}
/* Function to get the size of the queue */
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 .
In this lab, we will write an application to store a deck of cards i.pdfcontact41
In this lab, we will write an application to store a deck of cards in a linked list, and then write
methods to sort and shuffle the deck.
Copy your completed LinkedList class from Lab 4 into the LinkedList.java file below.
Complete all methods of the Card class as described by the Javadoc comments. The class
contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are
divided. The rank is the relative importance of the card within its suit.
Note that the Card constructor must convert any rank and suit letters to uppercase.
For the equals() method, be sure to follow the steps outlined in Lesson 4. How to implement the
compareTo() method is also covered in Lesson 4.
Note that you are not allowed to add any additional methods or member variables to this class or
you will not receive credit for this assignment.
Complete all methods of the CardApp class in the CardApp.java file as described by the Javadoc
comments.
You may add as many methods as you would like to this file, but are not allowed to add any
additional member variables.
The CardApp program must prompt for and allow the user to enter the name of any input file as
shown in the Example output below.
Implement the shuffle() method as specified in the comments for shuffle(). After you have
shuffled the deck of cards, write the result into a file named shuffled.txt.
Implement the sort() method using bubble sort from Lesson 4. First sort by suit in alphabetical
order and then by rank from 2 to A. The pseudocode for bubble sort is as follows:
After you have sorted the deck of cards, write the result to a file named sorted.txt.
The CardApp.java file also contains the main() method of the application. Use Develop mode to
test your CardApp code along with your Card and LinkedList code.
All input and output files must contain a list of cards, with each card stored on its own line. See
the example files cards1.txt and cards2.txt for example file formats.
[[[cards1.txt]]]
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
[[[cards2.txt]]]
AS
2S
3S
4S
5S
6S
7S
8S
9S
10S
JS
QS
KS
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AH
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
QH
KH
AD
2D
3D
4D
5D
6D
7D
8D
9D
10D
JD
QD
KD
[[[CardApp.java]]]
/**
* CardApp.java
* @author Your name
* @author Partner's name
* CIS 22C, Applied Lab 1
*/
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public vo.
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.
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 .
student start_code_U08223_cwk1 (1)/.DS_Store
__MACOSX/student start_code_U08223_cwk1 (1)/._.DS_Store
student start_code_U08223_cwk1 (1)/Connection.javastudent start_code_U08223_cwk1 (1)/Connection.java
package cwk1test;
/**
* Interface to be implemented by classes representing undirected connections
* between Stations in a Network
*
* N.B. You may change the package name for this interface, but you should
* not modify it in any other way.
*/
publicinterfaceConnection{
/**
* Get the distance value for this Connection
*
* @return distance value for the Connection
*/
double getDistance();
/**
* Get a reference to one of the stations that are linked by this Connection
* The returned Sation is different to that returned by getStationB()
*
* @return a reference to one of the Stations linked by this Connection
*/
Station getStationA();
/**
* Get a reference to one of the stations that are linked by this Connection
* The returned Sation is different to that returned by getStationA()
*
* @return a reference to one of the Stations linked by this Connection
*/
Station getStationB();
/**
* Given one of the stations linked by this Connection, return the other
*
* @param station one of the Stations linked by the Connection
* @return the other Station
* PRECONDITION: station==getStationA() || station==getStationB()
*/
Station getOtherStation(Station station);
}
__MACOSX/student start_code_U08223_cwk1 (1)/._Connection.java
student start_code_U08223_cwk1 (1)/GraphicsUtil.javastudent start_code_U08223_cwk1 (1)/GraphicsUtil.java/**
* Utility glass for drawing networks
*/
package cwk1test;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import javax.swing.JComponent;
/**
*
* @author p0073862
*/
publicclassGraphicsUtil{
privatestaticfinaldouble NOTIONAL_WIDTH =255;
privatestaticfinaldouble NOTIONAL_HEIGHT =255;
privatestaticfinalint CIRCLE_RADIUS =5;
privatestaticfinalint[] xPoints =newint[2];
privatestaticfinalint[] yPoints =newint[2];
/**
* Draw a network onto a component
*
*
* @param network Network to be drawn
* @param component Component on to which the network is to be drawn (e.g a
* JPanel)
* @param g Graphics object used for drawing
*/
publicstaticvoid drawNetwork(Network network,JComponent component,
Graphics g){
Color oldColor = g.getColor();
double xScale = component.getWidth()/ NOTIONAL_WIDTH;
double yScale = component.getHeight()/ NOTIONAL_HEIGHT;
for(Station station : network.getStations()){
FontMetrics metrics = g.getFontMetrics();
int textHeight = metrics.getHeight();
int x =(int)Math.round(xScale * station.getxPos())- CIRCLE_RADIUS;
int y =(int)Math.round(yScale * station.getyPos())- CIRCLE_RADIUS;
int diameter = CIRCLE_RADIUS *2;
g.setColor(Color.BLACK);
g.fillOval(x, y, diameter, diameter);
g.setColor(Color.RED).
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfmail931892
How do I fix it in LinkedList.java?
LabProgram.java
LinkedList.java:
/**
* Defines a doubly-linked list class
* @author
* @author
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
if (iterator != null){
return iterator.data;
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
if(iterator != null){
Node newNode = new Node(data);
newNode.next = iterator.next;
iterator.next = newNode;
if (iterator == first){
first = newNode;
}
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/
public void removeFirst() throws NoS.
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdfganisyedtrd
// USING UNITY TRYING TO CREATE A CLICK TO PATH, THAT YOU CLICK ON AND
THE AGENT/AVATAR FOLLOWS THE BEST PATH TO GET THERE
// AT THE SAME TIME THERE IS A GUARD CHASING THE AGENT USING
AWARENESS AND PAHTFINDING.
//THIS IS THE MapManager.cs the Agent.cs I could upload it
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
// Custom struct to hold the per-tile information needed for the A* pathing search
public struct grid_cell
{
public bool visited;
public bool isBlocked;
public Vector2Int parent;
public float g, h, f;
}
public class MapManager : MonoBehaviour
{
// fixed map size for simplicity - map file must match
public const int WIDTH = 12;
public const int HEIGHT = 12;
// need to know tile size (color for debugging)
private Vector2 TILE_SIZE;
private Color TILE_COLOR;
// prefab tiles (and debugging labels)
public GameObject[] _tilePrefabs;
public GameObject _labelPrefab;
public GameObject _uiCanvas;
// A* pathfinding array and queue
private grid_cell[,] _map = new grid_cell[WIDTH, HEIGHT];
private List<KeyValuePair<float, Vector2Int>> _openList = new List<KeyValuePair<float,
Vector2Int>>();
// references to tile spriterenderers and tile labels for debugging
private SpriteRenderer[,] _tiles = new SpriteRenderer[WIDTH, HEIGHT];
private Text[,] _labels = new Text[WIDTH, HEIGHT];
// steps is a convenient way to generate the 8 children of a grid square
private Vector2Int[] _steps = new Vector2Int[8];
void Start()
{
TILE_SIZE = _tilePrefabs[0].transform.GetComponent<SpriteRenderer>()
.bounds.extents * 2;
// load map and create tiles
readMapFile();
// for debugging, store the color of an unblocked tile (for changing them back)
TILE_COLOR = _tiles[0,0].color;
// store "step" vectors for the four cardinal directions
_steps[0].x = -1; _steps[0].y = 0;
_steps[1].x = 0; _steps[1].y = -1;
_steps[2].x = 0; _steps[2].y = 1;
_steps[3].x = 1; _steps[3].y = 0;
// and the four diagonal directions
_steps[4].x = 1; _steps[4].y = 1;
_steps[5].x = 1; _steps[5].y = -1;
_steps[6].x = -1; _steps[6].y = 1;
_steps[7].x = -1; _steps[7].y = -1;
}
/*********************************************************************************************
Collision with blocked tiles (walls)
- called by agents
- returns a response vector indicating the amount to "push" the agent out of the walls
- (0,0) indicates no collisions happening
*/
public Vector2 checkBlockedCollision(Vector2 pos, Vector2 extents)
{
// convert the world position that we're checking to the coordinates of a grid cell
Vector2Int posGC = vectorToGC(pos);
// loop over the diagonal steps to check the diagonally-adjacent cells
// check those first, because a diagonal collision implies two cardinal direction collisions
for (int si=4;si<_steps.Length;si++) {
// for each diagonal neighbor
Vector2Int step = _steps[si];
Vector2Int neighbor = posGC + step;
// if it's not on the map or not blocked, then no collision possible
if (!onMap(neighbor)) continue;
if.
This presentation provides an overview of key topics in Java class design; also covers best practices/tips and quiz questions. Based on our OCP 8 book.
Production.javapublic class Production { Declaring instance.pdfsooryasalini
Production.java
public class Production {
//Declaring instance variables
private String title;
private String director;
private String writer;
//Parameterized constructor
public Production(String title, String director, String writer) {
super();
this.title = title;
this.director = director;
this.writer = writer;
}
//Setters and getters.
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Title: \" + this.title);
System.out.println(\"Director: \" + this.director);
System.out.println(\"Writer: \" + this.writer);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return \"Title :\" + title + \"\ Director :\" + director
+ \"\ Writer :\" + writer;
}
}
___________________________________________
Film.java
public class Film extends Production{
//Declaring instance variables
private int boxOfficeGross;
//Parameterized constructor
public Film(String title, String director, String writer, int boxOfficeGross) {
super(title, director, writer);
this.boxOfficeGross = boxOfficeGross;
}
//Setters and getters.
public int getBoxOfficeGross() {
return boxOfficeGross;
}
public void setBoxOfficeGross(int boxOfficeGross) {
this.boxOfficeGross = boxOfficeGross;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"BoxOfiiceGross: \" + this.boxOfficeGross);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ BoxOfficeGross :\" + boxOfficeGross+\"\ \";
}
}
_______________________________________________
Play.java
public class Play extends Production {
//Declaring instance variables
private int performances;
//Parameterized constructor
public Play(String title, String director, String writer, int performances) {
super(title, director, writer);
this.performances = performances;
}
//Setters and getters.
public int getPerformances() {
return performances;
}
public void setPerformances(int performances) {
this.performances = performances;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Performances: \" + this.performances);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ Performances :\" + performances+\"\ \";
}
}
_______________________________________________
Musical.java
public class BobsTerribleTests
{
public static void main(String[] args)
{
//Creating an Film Object by passing parameters
Film titanic = new Film(\"Titanic\", \"James Cameron\", \"James Cameron\.
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 .
Stuck with your Ruby Programming Assignment. Get 24/7 help from tutors with Phd in the subject. Email us at support@helpwithassignment.com
Reach us at http://www.HelpWithAssignment.com
Get 24/7 Reliable Ruby programming Assignment Help, 100% error free, money back guarantee, Phd level tutors, A grade guarantee, www.HelpwithAssignment.com or email us at support@helpwithassignment.com
Give examples of system which can achieve some security requirement.pdfdbrienmhompsonkath75
Give examples of system which can achieve some security requirement?
Solution
Answer:
The security of the system depends upon these four pillars :
1. Secrecy
2. Integrity
3. Accountability
4. Availibility
Every computer must be aware about the security and must decide what is security to it. It is like
a legal law in some country can be illegal for other country..
Help me with these questions please.1. Name four characteristics t.pdfdbrienmhompsonkath75
Help me with these questions please.
1. Name four characteristics that are used to describe single variable data.
2. What are the advantages of using a stemplot over a histogram? What are the disadvantages?
3. What are the advantages of using the mean as the center? What are the disadvantages?
4. What are the advantages of using the median as the center? What are the disadvantages?
5. What type of graph is used for bivariate data?
6. What is the difference between explanatory and response variables?
7. What does the correlation coefficient, r, measure?
8. What is the range of values of r?
9. What does the coefficient of determination, r^2, measure?
10. What is the range of values of r^2?
11. How is a residual plot constructed?
12. How is a residual plot interpreted?
Solution
1) i. Randomness ii. Presentable iii. Reliable iv. Genuine
2) Stemplot gives list of values as it is in a easy form of presentation.
Disadvantage is while histogram enables comparison about the data, stemplot just presents data
in a grouped form
3) Mean is easily understood and also a good central measure. So many distributions we find that
sample mean estimates population parameter but disadvantage of mean is it is affected by
extreme items or outliers thus giving wrong picture about average.
4) Median is reliable and not affected by outliers as it is affectd only by the order of the item.
The disadvantage is that for continuous data, it is not possible always to arrange in ascending and
find median.
5) Planar graph with 2 coordinates used for bivariate data.
6) Explanatory variable is the independent variable which can take any value but response
variable value depends on the value of explanatory variable
7) Correlation coefficient measures the dependence or association of two variables
8) r lies between -1 and +1
9) Coefficient of determination represent variation of y wrt x. It is square of r, and always
positive thus gives a clear picture of relation between x and y.
10) r^2 varies from 0 to 1
11) Residual plot is constructed using scatter diagram and least square line.
REsidue plot is the deviation of actual from estimated regression curve.
12) REsidual plot is the absolute difference of y and y estimate..
More Related Content
Similar to java question Fill the add statement areaProject is to wo.pdf
There is something wrong with my program-- (once I do a for view all t.pdfaashienterprisesuk
There is something wrong with my program.. (once I do a for view all this is the outcome in the
console...(carnea:Name: carnea, Address: 30 repeated..) why is this?
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
action = scanner.nextLine();
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
public class Node {
private String name;
private String address;
private Node next;
public Node(String name, String address) {
// add here ..
this.name = name;
this.address = address;
}
public String getName() {
// add here ..
return this.name;
}
public void setName(String name) {
// add here ..
this.name = name;
}
public String getAddress() {
// add here ..
return this.address;
}
public void setAddress(String address) {
// add here ..
this.address = address;
}
public Node getNext() {
// add here ..
return this.next;
}
public String toString() {
return "Name: "+ name +", Address:" +address;
}
public void setNext(Node node) {
// add here ..
this.next = next;
}
public void setAddress (Object newValue) {
this.address = address;
}
public void setName(Object newValue) {
this.name = name;
}
}
import java.util.Scanner;
public class Tablea {
private Node mark;
public Node get.
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfmail931892
How do I fix it in LinkedList.java?
this is what i did
LabProgram.java
LinkedList.java:
/**
* Defines a doubly-linked list class
* @author
* @author
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
if (iterator != null){
return iterator.data;
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
if(iterator != null){
Node newNode = new Node(data);
newNode.next = iterator.next;
iterator.next = newNode;
if (iterator == first){
first = newNode;
}
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/
public void remov.
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
Using NetBeans
Implement a queue named QueueLL using a Linked List (same as we did for the stack). This
implementation must be used in all the following problems.
Implement a queue QueueST using a stack (use StackLL).
Test your implementations in the main with examples.
Solution
Answer:-
import java.util.*;
/* Class Node */
class Node
{
protected int data;
protected Node link;
/* Constructor */
public Node()
{
link = null;
data = 0;
}
/* Constructor */
public Node(int d,Node n)
{
data = d;
link = n;
}
/* Function to set link to next Node */
public void setLink(Node n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(int d)
{
data = d;
}
/* Function to get link to next node */
public Node getLink()
{
return link;
}
/* Function to get data from current Node */
public int getData()
{
return data;
}
}
/* Class linkedQueue */
class linkedQueue
{
protected Node front, rear;
public int size;
/* Constructor */
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
/* Function to check if queue is empty */
public boolean isEmpty()
{
return front == null;
}
/* Function to get the size of the queue */
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 .
In this lab, we will write an application to store a deck of cards i.pdfcontact41
In this lab, we will write an application to store a deck of cards in a linked list, and then write
methods to sort and shuffle the deck.
Copy your completed LinkedList class from Lab 4 into the LinkedList.java file below.
Complete all methods of the Card class as described by the Javadoc comments. The class
contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are
divided. The rank is the relative importance of the card within its suit.
Note that the Card constructor must convert any rank and suit letters to uppercase.
For the equals() method, be sure to follow the steps outlined in Lesson 4. How to implement the
compareTo() method is also covered in Lesson 4.
Note that you are not allowed to add any additional methods or member variables to this class or
you will not receive credit for this assignment.
Complete all methods of the CardApp class in the CardApp.java file as described by the Javadoc
comments.
You may add as many methods as you would like to this file, but are not allowed to add any
additional member variables.
The CardApp program must prompt for and allow the user to enter the name of any input file as
shown in the Example output below.
Implement the shuffle() method as specified in the comments for shuffle(). After you have
shuffled the deck of cards, write the result into a file named shuffled.txt.
Implement the sort() method using bubble sort from Lesson 4. First sort by suit in alphabetical
order and then by rank from 2 to A. The pseudocode for bubble sort is as follows:
After you have sorted the deck of cards, write the result to a file named sorted.txt.
The CardApp.java file also contains the main() method of the application. Use Develop mode to
test your CardApp code along with your Card and LinkedList code.
All input and output files must contain a list of cards, with each card stored on its own line. See
the example files cards1.txt and cards2.txt for example file formats.
[[[cards1.txt]]]
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
[[[cards2.txt]]]
AS
2S
3S
4S
5S
6S
7S
8S
9S
10S
JS
QS
KS
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AH
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
QH
KH
AD
2D
3D
4D
5D
6D
7D
8D
9D
10D
JD
QD
KD
[[[CardApp.java]]]
/**
* CardApp.java
* @author Your name
* @author Partner's name
* CIS 22C, Applied Lab 1
*/
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public vo.
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.
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 .
student start_code_U08223_cwk1 (1)/.DS_Store
__MACOSX/student start_code_U08223_cwk1 (1)/._.DS_Store
student start_code_U08223_cwk1 (1)/Connection.javastudent start_code_U08223_cwk1 (1)/Connection.java
package cwk1test;
/**
* Interface to be implemented by classes representing undirected connections
* between Stations in a Network
*
* N.B. You may change the package name for this interface, but you should
* not modify it in any other way.
*/
publicinterfaceConnection{
/**
* Get the distance value for this Connection
*
* @return distance value for the Connection
*/
double getDistance();
/**
* Get a reference to one of the stations that are linked by this Connection
* The returned Sation is different to that returned by getStationB()
*
* @return a reference to one of the Stations linked by this Connection
*/
Station getStationA();
/**
* Get a reference to one of the stations that are linked by this Connection
* The returned Sation is different to that returned by getStationA()
*
* @return a reference to one of the Stations linked by this Connection
*/
Station getStationB();
/**
* Given one of the stations linked by this Connection, return the other
*
* @param station one of the Stations linked by the Connection
* @return the other Station
* PRECONDITION: station==getStationA() || station==getStationB()
*/
Station getOtherStation(Station station);
}
__MACOSX/student start_code_U08223_cwk1 (1)/._Connection.java
student start_code_U08223_cwk1 (1)/GraphicsUtil.javastudent start_code_U08223_cwk1 (1)/GraphicsUtil.java/**
* Utility glass for drawing networks
*/
package cwk1test;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import javax.swing.JComponent;
/**
*
* @author p0073862
*/
publicclassGraphicsUtil{
privatestaticfinaldouble NOTIONAL_WIDTH =255;
privatestaticfinaldouble NOTIONAL_HEIGHT =255;
privatestaticfinalint CIRCLE_RADIUS =5;
privatestaticfinalint[] xPoints =newint[2];
privatestaticfinalint[] yPoints =newint[2];
/**
* Draw a network onto a component
*
*
* @param network Network to be drawn
* @param component Component on to which the network is to be drawn (e.g a
* JPanel)
* @param g Graphics object used for drawing
*/
publicstaticvoid drawNetwork(Network network,JComponent component,
Graphics g){
Color oldColor = g.getColor();
double xScale = component.getWidth()/ NOTIONAL_WIDTH;
double yScale = component.getHeight()/ NOTIONAL_HEIGHT;
for(Station station : network.getStations()){
FontMetrics metrics = g.getFontMetrics();
int textHeight = metrics.getHeight();
int x =(int)Math.round(xScale * station.getxPos())- CIRCLE_RADIUS;
int y =(int)Math.round(yScale * station.getyPos())- CIRCLE_RADIUS;
int diameter = CIRCLE_RADIUS *2;
g.setColor(Color.BLACK);
g.fillOval(x, y, diameter, diameter);
g.setColor(Color.RED).
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfmail931892
How do I fix it in LinkedList.java?
LabProgram.java
LinkedList.java:
/**
* Defines a doubly-linked list class
* @author
* @author
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
if (iterator != null){
return iterator.data;
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
if(iterator != null){
Node newNode = new Node(data);
newNode.next = iterator.next;
iterator.next = newNode;
if (iterator == first){
first = newNode;
}
}else{
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
/
public void removeFirst() throws NoS.
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdfganisyedtrd
// USING UNITY TRYING TO CREATE A CLICK TO PATH, THAT YOU CLICK ON AND
THE AGENT/AVATAR FOLLOWS THE BEST PATH TO GET THERE
// AT THE SAME TIME THERE IS A GUARD CHASING THE AGENT USING
AWARENESS AND PAHTFINDING.
//THIS IS THE MapManager.cs the Agent.cs I could upload it
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
// Custom struct to hold the per-tile information needed for the A* pathing search
public struct grid_cell
{
public bool visited;
public bool isBlocked;
public Vector2Int parent;
public float g, h, f;
}
public class MapManager : MonoBehaviour
{
// fixed map size for simplicity - map file must match
public const int WIDTH = 12;
public const int HEIGHT = 12;
// need to know tile size (color for debugging)
private Vector2 TILE_SIZE;
private Color TILE_COLOR;
// prefab tiles (and debugging labels)
public GameObject[] _tilePrefabs;
public GameObject _labelPrefab;
public GameObject _uiCanvas;
// A* pathfinding array and queue
private grid_cell[,] _map = new grid_cell[WIDTH, HEIGHT];
private List<KeyValuePair<float, Vector2Int>> _openList = new List<KeyValuePair<float,
Vector2Int>>();
// references to tile spriterenderers and tile labels for debugging
private SpriteRenderer[,] _tiles = new SpriteRenderer[WIDTH, HEIGHT];
private Text[,] _labels = new Text[WIDTH, HEIGHT];
// steps is a convenient way to generate the 8 children of a grid square
private Vector2Int[] _steps = new Vector2Int[8];
void Start()
{
TILE_SIZE = _tilePrefabs[0].transform.GetComponent<SpriteRenderer>()
.bounds.extents * 2;
// load map and create tiles
readMapFile();
// for debugging, store the color of an unblocked tile (for changing them back)
TILE_COLOR = _tiles[0,0].color;
// store "step" vectors for the four cardinal directions
_steps[0].x = -1; _steps[0].y = 0;
_steps[1].x = 0; _steps[1].y = -1;
_steps[2].x = 0; _steps[2].y = 1;
_steps[3].x = 1; _steps[3].y = 0;
// and the four diagonal directions
_steps[4].x = 1; _steps[4].y = 1;
_steps[5].x = 1; _steps[5].y = -1;
_steps[6].x = -1; _steps[6].y = 1;
_steps[7].x = -1; _steps[7].y = -1;
}
/*********************************************************************************************
Collision with blocked tiles (walls)
- called by agents
- returns a response vector indicating the amount to "push" the agent out of the walls
- (0,0) indicates no collisions happening
*/
public Vector2 checkBlockedCollision(Vector2 pos, Vector2 extents)
{
// convert the world position that we're checking to the coordinates of a grid cell
Vector2Int posGC = vectorToGC(pos);
// loop over the diagonal steps to check the diagonally-adjacent cells
// check those first, because a diagonal collision implies two cardinal direction collisions
for (int si=4;si<_steps.Length;si++) {
// for each diagonal neighbor
Vector2Int step = _steps[si];
Vector2Int neighbor = posGC + step;
// if it's not on the map or not blocked, then no collision possible
if (!onMap(neighbor)) continue;
if.
This presentation provides an overview of key topics in Java class design; also covers best practices/tips and quiz questions. Based on our OCP 8 book.
Production.javapublic class Production { Declaring instance.pdfsooryasalini
Production.java
public class Production {
//Declaring instance variables
private String title;
private String director;
private String writer;
//Parameterized constructor
public Production(String title, String director, String writer) {
super();
this.title = title;
this.director = director;
this.writer = writer;
}
//Setters and getters.
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Title: \" + this.title);
System.out.println(\"Director: \" + this.director);
System.out.println(\"Writer: \" + this.writer);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return \"Title :\" + title + \"\ Director :\" + director
+ \"\ Writer :\" + writer;
}
}
___________________________________________
Film.java
public class Film extends Production{
//Declaring instance variables
private int boxOfficeGross;
//Parameterized constructor
public Film(String title, String director, String writer, int boxOfficeGross) {
super(title, director, writer);
this.boxOfficeGross = boxOfficeGross;
}
//Setters and getters.
public int getBoxOfficeGross() {
return boxOfficeGross;
}
public void setBoxOfficeGross(int boxOfficeGross) {
this.boxOfficeGross = boxOfficeGross;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"BoxOfiiceGross: \" + this.boxOfficeGross);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ BoxOfficeGross :\" + boxOfficeGross+\"\ \";
}
}
_______________________________________________
Play.java
public class Play extends Production {
//Declaring instance variables
private int performances;
//Parameterized constructor
public Play(String title, String director, String writer, int performances) {
super(title, director, writer);
this.performances = performances;
}
//Setters and getters.
public int getPerformances() {
return performances;
}
public void setPerformances(int performances) {
this.performances = performances;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Performances: \" + this.performances);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ Performances :\" + performances+\"\ \";
}
}
_______________________________________________
Musical.java
public class BobsTerribleTests
{
public static void main(String[] args)
{
//Creating an Film Object by passing parameters
Film titanic = new Film(\"Titanic\", \"James Cameron\", \"James Cameron\.
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 .
Stuck with your Ruby Programming Assignment. Get 24/7 help from tutors with Phd in the subject. Email us at support@helpwithassignment.com
Reach us at http://www.HelpWithAssignment.com
Get 24/7 Reliable Ruby programming Assignment Help, 100% error free, money back guarantee, Phd level tutors, A grade guarantee, www.HelpwithAssignment.com or email us at support@helpwithassignment.com
Give examples of system which can achieve some security requirement.pdfdbrienmhompsonkath75
Give examples of system which can achieve some security requirement?
Solution
Answer:
The security of the system depends upon these four pillars :
1. Secrecy
2. Integrity
3. Accountability
4. Availibility
Every computer must be aware about the security and must decide what is security to it. It is like
a legal law in some country can be illegal for other country..
Help me with these questions please.1. Name four characteristics t.pdfdbrienmhompsonkath75
Help me with these questions please.
1. Name four characteristics that are used to describe single variable data.
2. What are the advantages of using a stemplot over a histogram? What are the disadvantages?
3. What are the advantages of using the mean as the center? What are the disadvantages?
4. What are the advantages of using the median as the center? What are the disadvantages?
5. What type of graph is used for bivariate data?
6. What is the difference between explanatory and response variables?
7. What does the correlation coefficient, r, measure?
8. What is the range of values of r?
9. What does the coefficient of determination, r^2, measure?
10. What is the range of values of r^2?
11. How is a residual plot constructed?
12. How is a residual plot interpreted?
Solution
1) i. Randomness ii. Presentable iii. Reliable iv. Genuine
2) Stemplot gives list of values as it is in a easy form of presentation.
Disadvantage is while histogram enables comparison about the data, stemplot just presents data
in a grouped form
3) Mean is easily understood and also a good central measure. So many distributions we find that
sample mean estimates population parameter but disadvantage of mean is it is affected by
extreme items or outliers thus giving wrong picture about average.
4) Median is reliable and not affected by outliers as it is affectd only by the order of the item.
The disadvantage is that for continuous data, it is not possible always to arrange in ascending and
find median.
5) Planar graph with 2 coordinates used for bivariate data.
6) Explanatory variable is the independent variable which can take any value but response
variable value depends on the value of explanatory variable
7) Correlation coefficient measures the dependence or association of two variables
8) r lies between -1 and +1
9) Coefficient of determination represent variation of y wrt x. It is square of r, and always
positive thus gives a clear picture of relation between x and y.
10) r^2 varies from 0 to 1
11) Residual plot is constructed using scatter diagram and least square line.
REsidue plot is the deviation of actual from estimated regression curve.
12) REsidual plot is the absolute difference of y and y estimate..
Describe current and emerging roles of the patient record in HIT toda.pdfdbrienmhompsonkath75
Describe current and emerging roles of the patient record in HIT today. Explain the relationship
of enterprise information systems and EHR systems. Why are standards an essential component
of HIT and EHR systems? Prepare a flowchart to contrast and illustrate how EHR systems work
in a hospital settings versus in an ambulatory setting.
Solution
1)Two goals were listed in ONC t plan:
patient-focused healthcare and population health.
Four themes were proposed under these two goals:
1) privacy and security, 2) interoperability,
3) adoption, and
4) collaborative governance.
The discussion of the future roles of HIM in HIT will revolve around the four objectives defined
by the ONC.
Ensuring that patient information is secure and protected;
Improving healthcare quality, reducing medical errors, reducing health disparities, and advancing
delivery of patient-centered medical care;Reducing healthcare costs resulting from inefficiency,
medical errors, inappropriate care, duplicative care, and incomplete information;
Providing appropriate information to help guide medical decisions at the time and place of care;
Ensuring that meaningful public input is included in development of such infrastructure;
Improving the coordination of care and information among hospitals, laboratories, physician
offices, and other entities for the secure and authorized exchange of healthcare information;
Improving public health activities and facilitating the early identification and rapid response to
public health threats;
Facilitating health and clinical research and healthcare quality;.
Dont change the templates, and just fill out the TODO parts on .pdfdbrienmhompsonkath75
Don\'t change the templates, and just fill out the // TODO parts on below of templates, please.
Instruction
Reimplement a program using List and ArrayList . Recall that it is a
little tricky to merge arrays of window orders when the arrays may have dierent
sizes. Using List to represent arrays of window orders is more convenient since
we can add a new window order if its size is not found in the existing orders.
To this end, we have added a new class called TotalOrder , which represents
a list of window orders. It contains methods to add a single window order or
another total order. These methods will ensure that the orders are propertly
merged by window sizes.
What to implement?
You will use in the methods for classes described above. The provided code
template has instruction in the comments above the methods that you will
implement.
Output
20 apartments with (Living room: 5 (6 X 8 window))(Master bedroom: 3 (4 X 6 window))
15 apartments with (Living room: 5 (6 X 8 window))(Master bedroom: 3 (4 X 6 window))
(Guest room: 2 (5 X 6 window))
10 apartments with (Living room: 5 (6 X 8 window))(Master bedroom: 3 (4 X 6 window))
(Guest room: 2 (5 X 6 window))(Guest room: 2 (5 X 6 window))
Window orders are:
225 6 X 8 window
135 4 X 6 window
70 5 X 6 window
Note
TotalOrder:
o add(WindowOrder newOrder): To add the “newOrder” at first check if a similar order is
already stored in the array list. You should check this within a loop structure. If it already exists
you should merge it with the similar window order using a method call to “add” (which is a
method declared in WindowOrder to merge the orders). Otherwise, simply add the “newOrder”
to the end of the array list through calling the “add” method of the array list. The method returns
the current object.
o add(TotalOrder that): this method makes use of the previous one. You should iterate over all of
the window orders listed in “that” and add them to the array list by passing each one of its
elements them as the input argument to the above “add” method.
o times(int num): for every element stored in the arraylist of the class, call “times” method and
pass “num” as the input argument to it.
o toString(): for every element stored in the arraylist, call its toString() method +”\ ”. Store the
result in a String variable and then return it.
- Apartment:
o orderForOneUnit(): create a new “TotalOrder” object. Add the window orders of every room
to the total order. Return the total order.
o totalOrder(): call the previous method to get the total order for one unit. Call the “times”
method of the total order and use number of apartments as input.
- Building:
o order(): declare and create a TotalOrder object. Add the total order of each apartment into the
object you just created and return it after the loop.
Templates
TotalOrder.java
import java.util.ArrayList;
import java.util.List;
// This class represents a collection of window orders using an ArrayList
public class TotalOrder {
List orders = new ArrayList.
Directions Problem 1. A female with Muppetrus bristle mates with a .pdfdbrienmhompsonkath75
Directions: Problem 1. A female with Muppetrus bristle mates with a male with Flonasean body
color, producing the following counts: F1 Generation Males Disease-Disease WIT-Disease WT-
WT Disease-WT 243 239 Females WT-Disease Disease Disease WT-WT Disease-WT 254 254
Solution
Parents are heterozygous. Given that each parent has one disease phenotype at one locus and
wild type at other locus.
Female\'s disease phenotype is Muppetrus bristle. Let its symbol be WT.
Cross is: +/disease (phenotype Muppetrus) crossed to +/disease (phenotype Flonasean)
The answer cannot be homozygous lethal because WT-WT and Disease-Disease are there.
Similarly it cannot be autosomal recessive, because in females Disease-Disease is 0.
This means that the mode of inheritance is sex-linked recessive.
In Drosophila males, crossing over does not occur. Only one X chromosome, which comes from
the female parent. So, genotype of males will be \"WT (wild type)\" phenotype on X-
chromosome. In females Disease-Disease is zero because of this..
Describe the roll of each of the following in membrane transport a.pdfdbrienmhompsonkath75
Describe the roll of each of the following in membrane transport
a.)facilities diffusion
b.)osmosis
c.)active transport
d.)endocytosis
e.)exocytosis
Solution
a)
Facilitated diffusion is the process of spontaneous passive passage of molecules or ions across a
cell\'s membrane passing through specific transmembrane integral proteins. Its role:
b) Osmosis is the net movement of water across a semipermeable membrane from an area of
lower solute concentration to an area of higher solute concentration.In other word it is the
diffusion of water down the water potential gradient. It’s role:
c) active transport:
d) and e) Exocytosis and endocytosis:Endocytosis and exocytosis are both forms of bulk
transport that move materials into and out of cells, respectively, via vesicles. not by membrane
transport..
Compare and contrast transactional and transformational leadership.pdfdbrienmhompsonkath75
Compare and contrast transactional and transformational leadership
Solution
Transactional leadership
The transactional leaders are works within the framework of self interest of his or her
constituency.
Classify about the transactional leaders are opinion leader, bureaucrats, executive leaders.
Transactional leaders effect over on efforts, satisfaction, and effectiveness of subordinates.
Transactional leaders are give the rewards and benefits whether positive or negative to
subordinates by fulfillment of agreement with the leader
Transactional leaders have four dimensions are contingent rewards, active management by
exception, passive management by exception, laissez-faire.
Transformational leadership
Transformational leader moves to change the framework.
Classify about the Transformational leader were categorized as intellectual leaders, leader of
reform, ideologues.
Transformational leaders asks followers to transcend their own self interest for the food of the
group, organization to consider their long term needs to develop, followers should aware of
really important needs.
Transformational leaders four dimension are charismatic, inspirational, intellectual stimulation,
and individualized consideration.
______________________________________________________________________.
Calculator Which of the following is not an asset Oa, owners equi.pdfdbrienmhompsonkath75
Calculator Which of the following is not an asset? Oa, owner\'s equity Oc. investments Od.
inventory
Solution
a.owner\'s equity
Asset is a component of balance sheet.Balance sheet is made of asset, liabilities and owners
equity.Other than a. all are assets. a. Is owners equity which is not asset..
You are installing a KVM switch for a small business customer so tha.pdfdbrienmhompsonkath75
You are installing a KVM switch for a small business customer so that he can use a single
keyboard, monitor, and mouse to manage two separate hardware servers. The KVM switch will
allow him to toggle back and forth between the two machines with the peripheral devices. To
successfully install the KVM switch, what special tools will you need?
A. A set of hex wrenches
B. A Phillips screwdriver
C. ESD protection devices
D. None
Solution
D. You shouldn’t need to use any special tools when installing the KVM switch, since the cable
connections are usually tightened by hand and you don’t need to open up any of the machines..
Why is metabolism important for physiological processesSolution.pdfdbrienmhompsonkath75
Why is metabolism important for physiological processes?
Solution
Answer:
Energy is needed for any type of physiological processes. A metabolism is a set of chemical
reactions, where energy is released that used for physiological processes like growth,
maintainance of structures, responding to the environment and reproduction. Hence the
metabolism is important for physiological processes..
Which macromolecule is primarily responsible for producing the pheno.pdfdbrienmhompsonkath75
Which macromolecule is primarily responsible for producing the phenotype of an organism?
a. proteins
b. carbs
c. lipids
d. DNA
e. mRNA
Solution
(a) Proteins
Phenotype is the physical characteristics of an organism and even though the DNA is the
blueprint, but the proteins produced by this DNA only determine our physical appearance. In this
aspect, proteins are the macromolecules which are primarily responsible for producing the
phenotype of an organism..
which invertebrate phylum is considered the most evolutionarily succe.pdfdbrienmhompsonkath75
which invertebrate phylum is considered the most evolutionarily successful as measured by
having the most species, producing the greatest number of offspring, and occupying the most
habitats? acopods. cnidarians echinoderms arthropods
Solution
D. Arthropods.
It is largest phylum in animal kingdom having more than 1 million species. Arthropods inhabitat
almost all the regions of globe. They found on land, in water, in air in burrows and underground..
What suggestions would you offer to parents and teachers who want to.pdfdbrienmhompsonkath75
What suggestions would you offer to parents and teachers who want to socialize children into
more androgynous and flexible gender roles? Be specific.
Solution
A) Parents treat sons and daughters alike (interact
equally, are equally warm) except for behaviour related to gender roles
• Dolls, dress-up, helping an adult are encouraged with girls
• Rough and tumble play is encouraged with boys
• Parents react more positively when children play with toys typical for their sex
• Fathers are more likely to encourage behaviour associated with gender stereotypes.
B) Many teachers and schools make gender salient in the classroom - eg. Separate lines for boys
and girls
• Might call on boys more than girls
• Are more likely to scold boys more for disruptive behaviour
• Since most elementary school teachers are female, classroom activities, readings, wall
dressings, etc. might be more appealing for girls
• When boys are not interested in something they tend not to do it..
What is the F2 generation when the F1 generation of +++y cv f is cr.pdfdbrienmhompsonkath75
What is the F2 generation when the F1 generation of +++/y cv f is crossed with +++/Y? Can
recombination be seen in the F2 generation?
Solution
Recombination seen in the F2 generation as +++/yY cv.
Two parental types, carrying either the Y+ y+ allele combination seen in the original mother (the
female of the P generation) or the Y y+ allele combination seen in the original father (the male of
the P generation). The remaining half of the gametes will be of two recombinant types, in which
reshuffling has produced either YY or Y y allele combinations not seen in the P generation
parents of the F1 females..
What features on the plasmid allows it to replicate independent o.pdfdbrienmhompsonkath75
What features on the plasmid allows it to replicate independent of the chromosomes
What features on the plasmid allows it to replicate independent of the chromosomes
Solution
Plasmids are the extra chromosomal DNA found in bacteria. Plasmids possesses a replicon or an
origin of replication of specific nucleotide sequence. This replicon helps the plasmids to replicate
independently. The tra genes or the transfer genes present in the plasmids helps them to get
transferred to the next generation with the help of relaxosome (a combination of DNA and tra
protein) which breaks one of the two strands of plasmid DNA and helps to unwind and it gets
treansferred throgh pilus. Mob genes also helps them for mobilisation during transformation.
Some plasmids undergo binary fission..
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdfdbrienmhompsonkath75
What are the use of Fibonacci numbers or the Golden Ratio in nature, art, music, architecture, or
some other real world application?
Solution
In the nature we can find some examples like:
- The arrangement of petals of flowers
- The distribution of leaves on a stem
Some structures are designe by this number, for example The Parthenon
In the music Bela Bartok (1881-1945), who have used such succession as a yardstick to
determine certain elements of his compositions
We can find many examples, because applications are diverse and varied.
Based on the following schematic with 3 D flip-flops, Write complete .pdfdbrienmhompsonkath75
Based on the following schematic with 3 D flip-flops, Write complete VHDL codes with clock
as input, and A, B, C are outputs
Solution
entity count is
Port ( Clock : in STD_LOGIC;
A,B,C : inout STD_LOGIC);
end count;
architecture Behavioral of count is
component DFF
Port ( Clock : in STD_LOGIC;
D : in STD_LOGIC;
Q : out STD_LOGIC);
end component;
signal DA,DB,DC:STD_LOGIC;
begin
DA<=(A xor \'1\');
DB<=(A xor B);
DC<=(A and B)xor C;
uA: DFF(Clock,DA,A);
uB: DFF(Clock,DB,B);
uC: DFF(Clock,DC,C);
end Behavioral;
//code for D Fliflop
entity DFF is
Port ( Clock : in STD_LOGIC;
D : in STD_LOGIC;
Q : out STD_LOGIC);
end DFF;
architecture Behavioral of DFF is
begin
process(clk,D)
begin
if(rising_edge(clk)) then
Q <= D;
end if;
end process;
end Behavioral;.
Although O_2 does not participate directly in the reactions of the TC.pdfdbrienmhompsonkath75
Although O_2 does not participate directly in the reactions of the TCA cycle, the cycle operates
only under aerobic conditions. Briefly explain this fact. How many ATP molecules are
generated during the complete oxidative degradation of phosphoenolpyruvate (PEP) to CO_2
and H_2O? Assume the glycerol phosphate shuttle is operating and show how you arrived at
your answer.
Solution
2) even though oxygen does not participate in the TCA Cycle but the ATP and NADPH
produced are passed in the ETC cycle where the oxygen acts as a electron transport.. Hence there
the role of oxygen takes place which is not found in the case of anaerobic situations..
3) when PEP gets converted to pyurvate I release 2 molecules of ATP.. But in this case only 1
ATP is produced as the one molecule of di-hydrooxyacetone phosphate converted to glyecerol-3-
phosphate by glycerol cycle hence in the glycolysis step 1 molecule gets reduced hence 1 ATP
gets reduced..!!.
8. Which of the following is NOT a transcriptionally repressed genom.pdfdbrienmhompsonkath75
8. Which of the following is NOT a transcriptionally repressed genomic region?
a. telomeres b. CpG islands c. one mating type locus in S. cerevisiaed. centromeres
Solution
b.CpG islands.
The CpG sites or CG sites are regions of DNA where a cytosine nucleotide occurs next to a
guanine nucleotide in the linear sequence of bases along its length.
CpG is a shorthand , cytosin and guanine separated by only one phosphate : phosphate links any
two nucleosides together in DNA.
It is not trancriptionally repressed genomic region..
49. Autonomic nervous system function is influenced by A) cerebral co.pdfdbrienmhompsonkath75
49. Autonomic nervous system function is influenced by A) cerebral cortex B) hypothalamus.
C) reticular system D) A and B only. E) A, B, and C
Solution
Theanswer is B)hypothalamus because the hypothalamus is usually present above the brain
stem.Moreover it works as an integrator for autonomic functions.This involves receiving and the
regulatory input from the limbic system to perform various actions which inclucdes the control
of respiration, cardiac regulation , vasomotor activity.ITalso regulates the cardiac regulation and
helps in reflex actions such as coughing, sneezing, swallowing..
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!
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
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.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
java question Fill the add statement areaProject is to wo.pdf
1. java question: "Fill the add statement area"
Project is to work with stacks.
package p2;
public class Coordinate {
public int x;
public int y;
public Coordinate( int x, int y ) {
this.x = x;
this.y = y;
}
public String toString() {
return "(" + this.x + "," + this.y + ")";
}
@Override
public boolean equals( Object object ) {
if( object == null ) {
return false;
}
if( ! Coordinate.class.isAssignableFrom( object.getClass() )) {
return false;
2. }
final Coordinate other = (Coordinate) object;
return this.x == other.x && this.y == other.y;
}
}
package p2;
public class Coordinate {
public int x;
public int y;
public Coordinate( int x, int y ) {
this.x = x;
this.y = y;
}
public String toString() {
return "(" + this.x + "," + this.y + ")";
}
@Override
public boolean equals( Object object ) {
if( object == null ) {
return false;
}
if( ! Coordinate.class.isAssignableFrom( object.getClass() )) {
3. return false;
}
final Coordinate other = (Coordinate) object;
return this.x == other.x && this.y == other.y;
}
}
package p2;
import java.util.Vector;
public class Maze {
private char[][] maze;
private int height;
private int width;
/**
* Create a new Maze of the specified height and width, initializing every
* location as empty, with a ' '.
**/
public Maze( int width, int height ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as blocked,
4. * marking it with a 'X'
**/
public void setBlocked( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as having been visited,
* marking it with a '*'
**/
public void setVisited( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as part of the path solution,
* marking it with a '.'
**/
public void setPath( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Returns the character at the locatio specified by the Coordinate
**/
public char at( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Returns a Coordinate array containing all Coordinates that are clear around
* the specified coordinate.
5. **/
public Coordinate[] clearAround( Coordinate coord ) {
Vector vector = new Vector();
// ADD STATEMENTS HERE
// Look at each of the locations around the specified Coordinate, and add it
// to the vector if it is clear (i.e. a space)
return vector.toArray( new Coordinate[0] );
}
/**
* Returns a Coordinate that provides the entrance location in this maze.
**/
public Coordinate start() {
return new Coordinate( 0, 1 );
}
/**
* Returns a Coordinate that provides the exit location from this maze.
**/
public Coordinate end() {
// ADD STATEMENTS HERE
}
/**
* The toString() method is responsible for creating a String representation
* of the Maze. See the project specification for sample output. Note that
* the String representation adds numbers across the top and side of the Maze
* to show the Coordinates of each cell in the maze.
**/
6. public String toString() {
StringBuilder buffer = new StringBuilder();
// ADD STATEMENTS HERE
// First, print out the column headings
// Next, print out each row in the maze - note the spaces between
// cells to facilitate reading. Each row should include its row number.
return buffer.toString();
}
}
package p2;
import java.util.Vector;
public class Maze {
private char[][] maze;
private int height;
private int width;
/**
* Create a new Maze of the specified height and width, initializing every
* location as empty, with a ' '.
**/
public Maze( int width, int height ) {
// ADD STATEMENTS HERE
}
7. /**
* Mutator to allow us to set the specified Coordinate as blocked,
* marking it with a 'X'
**/
public void setBlocked( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as having been visited,
* marking it with a '*'
**/
public void setVisited( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Mutator to allow us to set the specified Coordinate as part of the path solution,
* marking it with a '.'
**/
public void setPath( Coordinate coord ) {
// ADD STATEMENTS HERE
}
/**
* Returns the character at the locatio specified by the Coordinate
**/
public char at( Coordinate coord ) {
// ADD STATEMENTS HERE
}
8. /**
* Returns a Coordinate array containing all Coordinates that are clear around
* the specified coordinate.
**/
public Coordinate[] clearAround( Coordinate coord ) {
Vector vector = new Vector();
// ADD STATEMENTS HERE
// Look at each of the locations around the specified Coordinate, and add it
// to the vector if it is clear (i.e. a space)
return vector.toArray( new Coordinate[0] );
}
/**
* Returns a Coordinate that provides the entrance location in this maze.
**/
public Coordinate start() {
return new Coordinate( 0, 1 );
}
/**
* Returns a Coordinate that provides the exit location from this maze.
**/
public Coordinate end() {
// ADD STATEMENTS HERE
}
/**
* The toString() method is responsible for creating a String representation
9. * of the Maze. See the project specification for sample output. Note that
* the String representation adds numbers across the top and side of the Maze
* to show the Coordinates of each cell in the maze.
**/
public String toString() {
StringBuilder buffer = new StringBuilder();
// ADD STATEMENTS HERE
// First, print out the column headings
// Next, print out each row in the maze - note the spaces between
// cells to facilitate reading. Each row should include its row number.
return buffer.toString();
}
}
package p2;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class MazeReader {
private String fileName;
private Maze maze;
public MazeReader( String fileName ) {
this.fileName = fileName;
this.maze = null;
10. }
public Maze open() throws FileNotFoundException {
Scanner scanner = new Scanner( new File( this.fileName ));
int width = scanner.nextInt();
int height = scanner.nextInt();
this.maze = new Maze( width, height );
// Remove new line after int
scanner.nextLine();
// ADD STATEMENTS HERE
// You will need to read in each line using the Scanner, and provide
// the row number and the line to the addLine method to add it to the Maze
return this.maze;
}
private void addLine( int row, String line ) {
// ADD STATEMENTS HERE
}
public static void main( String[] args ) throws FileNotFoundException {
MazeReader reader = new MazeReader( "sampleMaze.txt" );
Maze maze = reader.open();
11. System.out.println( maze );
System.out.println( maze.at( new Coordinate( 0, 0 )));
System.out.println( maze.at( new Coordinate( 0, 1 )));
}
}
package p2;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class MazeReader {
private String fileName;
private Maze maze;
public MazeReader( String fileName ) {
this.fileName = fileName;
this.maze = null;
}
public Maze open() throws FileNotFoundException {
Scanner scanner = new Scanner( new File( this.fileName ));
int width = scanner.nextInt();
int height = scanner.nextInt();
this.maze = new Maze( width, height );
12. // Remove new line after int
scanner.nextLine();
// ADD STATEMENTS HERE
// You will need to read in each line using the Scanner, and provide
// the row number and the line to the addLine method to add it to the Maze
return this.maze;
}
private void addLine( int row, String line ) {
// ADD STATEMENTS HERE
}
public static void main( String[] args ) throws FileNotFoundException {
MazeReader reader = new MazeReader( "sampleMaze.txt" );
Maze maze = reader.open();
System.out.println( maze );
System.out.println( maze.at( new Coordinate( 0, 0 )));
System.out.println( maze.at( new Coordinate( 0, 1 )));
}
}
package p2;
13. import java.io.FileNotFoundException;
public class MazeSolver {
private Maze maze;
private LinkedStack path;
public MazeSolver( Maze maze ) {
// ADD STATEMENTS HERE
}
public void solve() {
// ADD STATEMENTS HERE
// Add the starting Coordinate to the maze, and while the Stack has
// entries, and the top of the Stack is not the end, continue searching
// for the path
}
public static void main( String[] args ) throws FileNotFoundException {
MazeReader reader = new MazeReader( "sampleMaze.txt" );
Maze maze = reader.open();
MazeSolver solver = new MazeSolver( maze );
System.out.println( "Before solving" );
System.out.println( maze );
System.out.println( "Start is " + maze.start() );
System.out.println( "End is " + maze.end() );
solver.solve();
System.out.println( "After solving (. shows solution, o shows visited)" );
System.out.println( maze );
14. }
}
package p2;
import java.io.FileNotFoundException;
public class MazeSolver {
private Maze maze;
private LinkedStack path;
public MazeSolver( Maze maze ) {
// ADD STATEMENTS HERE
}
public void solve() {
// ADD STATEMENTS HERE
// Add the starting Coordinate to the maze, and while the Stack has
// entries, and the top of the Stack is not the end, continue searching
// for the path
}
public static void main( String[] args ) throws FileNotFoundException {
MazeReader reader = new MazeReader( "sampleMaze.txt" );
Maze maze = reader.open();
MazeSolver solver = new MazeSolver( maze );
System.out.println( "Before solving" );
System.out.println( maze );
System.out.println( "Start is " + maze.start() );
System.out.println( "End is " + maze.end() );
15. solver.solve();
System.out.println( "After solving (. shows solution, o shows visited)" );
System.out.println( maze );
}
}
Consider a maze made up of a rectangular array of squares. The maze will contain a character
(either +, -, or |) to represent a blocked square, and to form the walls of the maze. Mazes will
have only one entrance at the Coordinate (0, 1), with only one exit in the lower right hand corner
of the maze.
Beginning at the entrance to the maze, find a path to the exit at the bottom right of the maze. You
may only move up, down, left, and right. Each square in the maze can be in one of four states:
clear (space), blocked (X), path (.), or visited (*). Initially, after the maze has been read in from
the file, each square will be either clear or blocked. If a square lies on a successful path, mark it
with a period. If you visit a square but it does not lead to a successful path, mark it as visited
with asterisk.
Consider a maze made up of a rectangular array of squares. The maze will contain a character
(either +, -, or |) to represent a blocked square, and to form the walls of the maze. Mazes will
have only one entrance at the Coordinate (0, 1), with only one exit in the lower right hand corner
of the maze.
Beginning at the entrance to the maze, find a path to the exit at the bottom right of the maze. You
may only move up, down, left, and right. Each square in the maze can be in one of four states:
clear (space), blocked (X), path (.), or visited (*). Initially, after the maze has been read in from
the file, each square will be either clear or blocked. If a square lies on a successful path, mark it
with a period. If you visit a square but it does not lead to a successful path, mark it as visited
with asterisk.
Solution
Got with two methods which are mainly required to run the main program:-
public Maze(int width,int height{
if(Maze.maze == null) {
16. throw new IllegalStateException("Error in setting the size");
}
if(width < 0 || width >= maze.length) {
throw new IllegalArgumentException("Row is Invalid.");
}
if(height < 0 || height >= maze[0].length) {
throw new IllegalArgumentException("Column in Invalid");
}
this.width = width;
this.height = height;
widthMinus1 = (width - 1);
heightMinus1 = (height - 1);
}
We are using the boolean array visited[][] which will set the value to true or false , if the path has
been
traversed already.
private boolean[][] visited = true;
public void solve(char[][]maze)
{
int x = maze[0].length;
int y = maze.length-2;
int d = -1;
boolean ok = false;
recursivesolution(maze,x,y,d);
}
// Defined for solving it recursively
public void recursivesolution(char[][]maze,int x, int y, int d)
{
boolean bool = false;
for (int j = 0;j<4 &&!bool;j++)
if (j!= d)
switch (j)
{
// Check for up right down and left
17. case 0:
if (maze[y-1][x] == ' ')
bool = recursivesolution(maze, x, y - 2, 2);
break;
case 1:
if (maze[y][x+1] == ' ')
bool = recursivesolution(maze, x + 2, y, 3);
break;
case 2:
if (maze[y+1][x] == ' ')
bool = recursivesolution(maze, x, y + 2, 0);
break;
case 3:
if (maze[y][x-1] == ' ')
bool = recursivesolution(maze, x - 2, y, 1);
break;
}
if (x == 1 && y == 1)
bool = true;
}