Complete this javascript question according to the
instructions
given in the comments.
*** DO NOT CHANGE any of the code that you are not instructed to. */
////////////////////
// Hint: If you see a console.log() in my examples, it is
// likely a "return" goes there in your assignment.
///////////////////
// 1) Define a "Vehicle" class that has a "wheels" property
equal to 4 in
// the constructor and a method named "rolling" that returns a
string
// equal to "Rolling down the highway on {wheels value}
wheels."
// Use the class to instantiate a new object named myRide.
// Define a "Car" subclass based on the parent class
"Vehicle".
// The "Car" class should also accept a parameter "carDoors".
The
// "Car" class should have a "doors" property that is set to
the
// value of the "carDoors" parameter. Add a method named
"doorsAndWheels"
// that returns a string equal to "My car has {doors value} doors
and
// {wheels value} wheels."
// Use the "Car" class to instantiate a new object named
myCruiser.
// Define a "Pie" class with the properties "flavor" and
"slices".
// Set the "flavor" property equal to a parameter named
"pieFlavor".
// Set the "slices" property equal to 8. Add a "getSlices"
method
// and a "setSlices" method that function as expected.
// Use the "Pie" class to instantiate a new object named
myDessert
// Define a Factory Function named "iceCreamFactory" that
// accepts a "iceCreamFlavor" parameter.
// The function will create an object that has a "flavor"
// property which is private. Set the "flavor" property
// value to the parameter "iceCreamFlavor" value.
// The function should also add a public "cone" property
// that has the value "waffle".
/////////////////////
// The factory function should add a method to the object
// it creates called "serve" that returns a string:
// "Here's your { flavor } ice cream in a { cone } cone."
///////////////////
// Hint: Look at this week's image for Factory Functions
////////
// Use iceCreamFactory to instantiate an object named myScoop.
// Using a literal (not a class or function), define an
object
// named "webDev" that has the following key-value pairs:
// foundation: "html", design: "css", logic: "javascript",
// build: function(){return "building..."}
// Convert the "webDev" object to JSON, and save the
converted
// data in a variable named sendJSON.
// Now convert the sendJSON data back to an object
// named receiveJSON.
In: Computer Science
Add your own method (or use one or more of the existing methods) to insert the following set of numbers (1, 5, 19, 7, 23, 17, 2) in a linked list (use one function call per number, and preserve the order of insertion). Once inserted print the linked list such that the output displays the numbers in reverse order. (2, 17, 23, 7, 19, 5, 1)
package linkedlist_app;
//-------class with main()-------------------
public class LinkedList_App {
public static void main(String[] args) {
linkedList myLL = new
linkedList();
System.out.println("----------------------------------");
//check for problems:
myLL.delete('A');
myLL.print();
myLL.insert_at_begining('A');
myLL.insert_after('X', 'A');
myLL.insert_at_end('E');
myLL.print();
myLL.delete('A');
myLL.print();
System.out.println("----------------------------------");
System.out.println("-- Free ALL
Nodes ----------------");
myLL.freeAll(); myLL.print();
System.out.println("----------------------------------");
System.out.println("--Insert at
begining: A, B, C ----");
myLL.insert_at_begining('A');
myLL.insert_at_begining('B');
myLL.insert_at_begining('C');
myLL.print();
}
}
//--------aNode
class---------------------------------------------
class aNode {
char data;
aNode next;
aNode(char mydata) { // Constructor
data = mydata;
next = null;
}
}
//------linkedList
class-----------------------------------------------
class linkedList {
aNode head; // Head of the linked list
aNode tail; //*** Tail of the linked list
int size;
linkedList() { // Constructor
head = null;// head point to
null
tail=null;//***tail also must point
to null
size =0;
}
//-----------------------------------------------------
public void insert_at_begining(char value)
{
aNode newNode = new aNode(value);
// create aNew node
if(isEmpty()){//***if the node is
inserted in empty node then head and tail are same
tail=newNode;
}
newNode.next = head;
head = newNode;
size++;
}
//-----------------------------------------------------
public void insert_at_end(char value) {
aNode newNode = new aNode(value);
// create aNew node
if (isEmpty())
{
insert_at_begining(value); //**reuse the code
already written
}else{ //**no
need to traverse the last node since reference of last node is in
tail
tail.next=newNode;
tail=newNode;
size++;
}
}
//-----------------------------------------------------
public void insert_after(char
value, char searchValue) {
if (isEmpty())
{
System.out.println("Linked List is empty, no way
to insert " + value + " after " + searchValue);
return;//***for simplicity of the code return
the control here
//***it eliminates complicated nested loop
}
//find the node
with searchValue
aNode
ptr;
boolean
found = false;
ptr =
head;
while (ptr
!= null && found == false) {
if (ptr.data == searchValue) {
found = true;
} else {
ptr = ptr.next;
}
}
if (ptr ==
null) {
System.out.println("Did not find " + searchValue
+ "Nothing Inserted");
return;//***for simplicity of the code return
the control here
//***it eliminates complicated nested loop
}
aNode newNode =
new aNode(value); // create aNew node
newNode.next =
ptr.next;
ptr.next =
newNode; //add the node after the searchValue
if(newNode.next==null)//***it is the last node
tail=newNode; //***point tail to the last
node
size++;
}
//-----------------------------------------------------
// Delete the first node with the
value
public void delete(char
deleteValue) {
if (isEmpty())
{
System.out.println("Linked List is empty,
nothing to delete");
return;//***for simplicity of the code return
the control here
//***it eliminates complicated nested loop
}
aNode
deletePtr = head; // create a reference to head
if
(head.data == deleteValue && head==tail) { //***only one
node in list
head = head.next; // remove the head and
tail=tail.next; //tail
deletePtr = null; // make the node available for
garbage collection.
size--;
return;//***for simplicity of the code return
the control here
//***it eliminates complicated nested loop
}
if(head.data==deleteValue){ //***first node to be deleted
head = head.next; // remove the head
deletePtr = null; // make the node available for
garbage collection.
size--;
return;//***for simplicity of the code return
the control here
//***it eliminates complicated nested loop
}
aNode
prevPtr;
deletePtr =
prevPtr = head;
boolean found =
false; //find the value to be deleted
while (deletePtr
!= null && found == false) {
if (deletePtr.data == deleteValue) {
found = true;
prevPtr.next =
deletePtr.next;
if(deletePtr.next==null)//***last node is deleted
tail=prevPtr;
deletePtr = null; // make
deletePtr available to garbage collection
size--;
} else {
prevPtr = deletePtr;
deletePtr =
deletePtr.next;
}
}
if (found ==
false) {
System.out.println("Not able to find/delete " +
deleteValue + " in the Linked List");
}
}
//-----------------------------------------------------
public boolean isEmpty() {
return
head==null;//***single line can work to check whether linked list
is empty or not
}
//-----------------------------------------------------
public void print() {
aNode ptr;
ptr =
head;
System.out.print("Head--> ");
while (ptr !=
null) {
System.out.print(ptr.data + " --> ");
ptr
= ptr.next;
}
System.out.println("NULL");
}
//-----------------------------------------------------
public int getSize() {
return(size);
}
//-----------------------------------------------------
public void freeAll() {
aNode freePtr =
head;
while(head !=
null) {
head = head.next; // the next two lines are
unnecessary, but are included for
// illustration of how memory is freed up
// freePtr = null;
// make the node available for garbage
collector
freePtr = head; // now let the freePtr to the
new head
}
head =
null;
size = 0;
}
}
//##############################################
//NOTE:- Changes made in the optimised code shown as *** in the
comment line
In: Computer Science
Write an explanation of what is an emerging technology? Provide background history about it, discuss why is it important today and in the future and give some examples on it?
In: Computer Science
Using Repl.it
In this assignment you will create a Java program that allows a Bank customer to do the following:
1) Create a bank account by supplying a user id and password
.2) Login using their id and password
3) Quit the program.
Now if login was successful the user will be able to do the following:
1) Withdraw money.
2) Deposit money.
3) Request balance.
4) Quit the program.
If login was not successful (for example the id or password did not match) then the user will be taken back to the introduction menu.
This is what your program in action will look like:
Hello
Welcome to Genesis Bank ATM Machine
Please select an option from the menu below:
l -> Login
c -> Create New Account
q -> Quit
> L
Please enter your user id: 12
Please enter your password: 2345
Create an Array List of about 10 Bank customers, basic money transactions for deposit, withdrawal, and balance checking.
In: Computer Science
A manufacturing company produces products. The following product information is stored: product name, product ID and quantity on hand. These products are made up of many components. Each component can be supplied by one or more suppliers. The following component information is kept: component ID, name, description, suppliers who supply them, and products in which they are used. Show table names, primary keys, attributes for each table, relationships between the entities including all constrains required.
Assumptions in your database design:
• A supplier can exist without providing components.
• A component must be associated with a supplier.
• A component must be associated with a product.
• A product cannot exist without components.
Design your database and implement it by providing all the required DDL and DML SQL statement to create the needed database objects and populate the tables with data. Make sure you included all required constraints and appropriates column datatypes.
Submit:
Write the sql code for creating these tables (the DDL statements).
Write query and update DML in SQL that must contain a where condition.
INSERT must populate all columns
Provide at least three statements for each type of DML • All needed constraints. Make sure you name all your constraints.
In: Computer Science
Please, i need Unique answer, Use your own words (don't copy and paste).
*Please, don't use handwriting.
|
<ol> |
|
<li id="Y"><a href ="home.php">HOME </a> </li> |
|
<li ><a id ="Z" href ="login.php">LOGIN </a> </li> |
|
<li><a href ="register.php">REGISTER </a> </li> |
|
</ol> |
|
<p>This is First paragraph </p> |
|
<p>This is Second paragraph with a <a href="link1.html">link 1</a> </p> |
|
<br /> |
|
<a href="link2.html">link 2</a> |
|
<p class="X"> This is Third Paragraph</p> |
|
<p class="X"> This is Fourth Paragraph</p> |
Write the CSS rules needed to:
In: Computer Science
The Project is:
1. Create a new Java program which implements a simple PacMan-type text game which contains the
following functionality:
A) At program startup, constructs and displays a 2-dimensional grid using standard array(s) (no
collection classes allowed) with the size dynamically specified by the user (X and Y sizes can
be different). Places the PacMan in the upper-left corner of the grid facing left All grid cells
should have the empty cell character of ‘.’ except for the start position of the PacMan which
will have the appropriate PacMan symbol (see below). Also 15% of your grid (rounded down if
necessary) should contain cookies randomly located on the grid except for the initial PacMan
position. The grid must be displayed after each command.
B) Use these symbols for the grid:
1. Cookie symbol – shows were cookies are in the grid ('O')
2. Empty symbol – shows empty unvisited grid cells ('.') (dot)
3. Visited symbol – shows grid cells where the PacMan has visited (' ') (space)
4. PacMan symbol depends on the current PacMan facing direction.
1. Left ‘>’
2. Up ‘V’
3. Right ‘<’
4. Down ‘^’
C) A menu of commands must be provided and must be displayed when appropriate. At a
minimum the menu should consists of the following commands (the command number is what
the user should enter to execute the command):
1. Menu – Display the menu of commands.
2. Turn Left – turns the PacMan left (counter-clockwise) but the PacMan stays in its current
location
1. Current: up, new: left
2. Current: right, new up
3. Current: down, new right
4. Current: left, new down
3. Turn Right – turns the PacMan right (clockwise) but the PacMan stays in its current location
1. Current: up, new: right
2. Current: right, new down
3. Current: down, new left
4. Current: left, new up
4. Move – Moves the PacMan one grid location in the facing direction if possible.
5. Exit – exits the program displaying the game statistics of the number of total moves and the
average number of moves per cookie obtained.
2. The main processing cycle is the following:
A) The grid must be displayed after each command showing the effects of the command.
B) Optionally display the list of commands
C) Display the grid
D) Accept user input. Code will be provided for reading user input.
1. If an invalid command is entered, an appropriate error message should be displayed and the
menu of commands and grid gets redisplayed. An invalid command does not count as a
command in the statistics.
2. Process the command and add one to the number of commands entered if it is a move
command.
3. If the user enters the Exit command, the program will display the number of commands and
the average number of commands per cookie.
E) If the resulting move places the PacMan over a cookie, indicate the cookie was eaten and add
one to the number of cookies eaten for the program statistics.
The solution on CHEGG does not solve the problem. The user has to input the rows and columns. PacMan needs to turn left, right, and move forward only. I am posting what I have so far below. I still need to figure out the turn, the move forward, the disappear dots/ cookies, and the statistics on exit. import java.util.Scanner; import java.util.Random; public class AssignmentMP1_dspicer83 { public static void main(String[] args) { // Creation of variables int play = 0; int columns = 0; int rows = 0; int cookies = 0; Random rnd = new Random(); Scanner scn = new Scanner(System.in); boolean quit = false; String [][] playArea; int area = 0; String menu = "Select from the following Menu\n" + "\t1. Display Menu\n" + "\t2. Turn Left\n" + "\t3. Turn Right\n" + "\t4. Move Forward\n" + "\t5. Exit"; //User input starts here while (!quit) { System.out.println("Welcome to my PacMan game \n" + "Would you like to play? \n" + "Press 1 to play and 2 to quit"); play = scn.nextInt(); if (play == 1) { // Game Play //columns is an x value System.out.println("How many columns would you like?"); columns = scn.nextInt(); //rows is an y value System.out.println("How many rows would you like?"); rows = scn.nextInt(); //Array created area = rows * columns; playArea = new String[rows][columns]; //calculate amount of cookies cookies = (int) ((columns * rows) * 0.15); //Any size and type String selectedIndex = ""; //create random variable Random rand = new Random(); //populates play area with PacMan and dots for(int i=0;i"; } else playArea[i][j]="."; } } //Any number< totalEmenent for(int i=0; i< cookies; i++) { int selectIndex = rand.nextInt(area); //generate random until its unique while(selectedIndex.indexOf(String.valueOf(selectIndex))> 0) { selectIndex = rand.nextInt(area); } //test if is original value selectedIndex = selectedIndex+selectIndex; int xCord = (int)selectIndex/playArea[0].length; int yCord = selectIndex%playArea[0].length; if(xCord == 0 && yCord == 0) { i--; } else playArea[xCord][yCord]="O"; } //Options Menu System.out.println(menu); //Main Game loop while (!quit) { //Print Grid for(int i=0;i")) { } break; case 3: //Turn Right break; case 4: //Move Forward break; case 5: //Exit System.out.println("Thanks for playing STATS"); quit = true; break; default: System.out.println("Please select options 1 - 5"); } } } else if (play ==2) { //User exit out of game System.out.println("Thank you for checking out my PacMan game. Please come back and play."); quit = true; } else { //in input is not 1 or 2, loops back to input start System.out.println("Not a valid option"); } } } }
In: Computer Science
Please explain this C++ below on how to get the following outputs (see code)
#include <iostream>
using namespace std;
// Tests for algorithm correctness
// -------------------------------
// 1 gives output "1 3 7 15 31 63 127 255 511
1023 2047"
// 2 gives output "2 5 11 23 47 95 191 383 767 1535
3071"
// 3 gives output "3 7 15 31 63 127 255 511 1023 2047
4095"
// 5 gives output "5 11 23 47 95 191 383 767 1535 3071
6143"
// Global variables
int X;
int I;
int main()
{
cout << "Enter starting value:
";
cin >> X;
cout << X;
cout << " ";
for (I = 1; I <= 10;
++I)
{
if ((X & 1) ==
0)
{
X
= X + 3;
}
else
{
X
= (2 * X) + 1;
}
cout << X
<< " ";
}
cout << endl
In: Computer Science
USING PYTHON
Our gift-wrapping department has ran out of wrapping paper. An order for more wrapping paper needs to be placed. There is a list, generated by the orders department, of the dimensions (length (l), width (w), and height (h)) of each box that needs to be gift wrapped. The list provides the dimensions of each box in inches, l×w×h.
We only need to order exactly as much wrapping paper as is needed and no more.
Fortunately, each package that needs gift wrapping is a cuboid. Which means that you can find the amount of gift-wrapping paper each box requires by finding the total surface area of the cuboid,
surface area=2(lw)+2(wh)+2(hl).
In addition to the surface area of the cuboid, you must also account for loss in the gift-wrapping production process. Each gift-wrapped box requires a loss amount, of wrapping paper, equal to the side of the cuboid with the smallest surface area.
For example
Using the list of boxes that need to be gift-wrapped, write a Python function that outputs the total number of square feet of wrapping paper that needs to be ordered.
https://courses.alrodrig.com/4932/boxes.txt
In: Computer Science
In: Computer Science
Give a CFG and (natural) PDA for the language { ai bj ck ef: i + j = k + f, i, j, k, f ≥ 0 }
In: Computer Science
Undecidability .20 marks
Let L1 = {M | M is a TM that halts on the empty tape leaving exactly two words on its tape in the form Bw1Bw2B} where B represents Blank like w1 w2 . (a) The problem of deciding whether an arbitrary Turing machine will accept an arbitrary input is undecidable. Prove formally using problem reduction, that given an arbitrary Turing machine M, the problem of deciding if M ∈ L1 is undecidable.
(b) Is L1 recursive, recursively enumerable, non-recursively enumerable, uncomputable? Justify your answer.
In: Computer Science
Q3) Our implementation of a doubly list relies on two sentinel nodes, header and trailer. Re-implement the DoublyLinkedList without using these nodes.
I want the answer to be a text not on a paper please
class DoublyLinkedList:
public class DoublyLinkedList {
public static class Node{
private E element;
private Node prev;
private Node next;
public Node(E e, Node p, Node n){
element = e;
prev = p;
next = n;
}
public E getElement() {
return element;
}
public Node getPrev() {
return prev;
}
public Node getNext() {
return next;
}
public void setPrev(Node p) {
next = p;
}
public void setNext(Node n) {
next = n;
}
}
private Node header;
private Node trailer;
private int size = 0;
public DoublyLinkedList(){
header = new Node<>(null,null,null);
trailer = new Node<>(null, header, null);
header.setNext(trailer);
}
public int size(){
return size;
}
public boolean isEmpty(){
return size ==0;
}
public E first(){
if(isEmpty())
return null;
return header.getNext().getElement();
}
public E last(){
if(isEmpty())
return null;
return trailer.getPrev().getElement();
}
}
In: Computer Science
An analysis of the emergency services responding to a hazardous chemical incident needs to be performed. In the scenario analyzed, some youths had broken into a farm and disturbed some chemicals in sacking. One of the youths had been taken to the hospital with respiratory problems, whilst the others were still at the scene. The police were sent to investigate the break-in at the farm. They called in the fire service to identify the chemical and clean up the spillage. The overall analysis shows four main sub-goals: receive notification of an incident, gather information about the incident, deal with the chemical incident, and resolve the incident. Perform a hierarchical task analysis for the above scenario. [Hint your answer should demonstrate all features of HTA Notations such as Selection, Iteration, Sequence and Unit task]
In: Computer Science
Write down a while loop that calculates and displays the SQUARE of ten ODD numbers (from 1 to 19) in a loop style execution:
C++
In: Computer Science