In: Computer Science
Write a code in arm 8086 keil software version 5 for signed input and perform addition and subtraction using both direct and indirect addressing mode.
In: Computer Science
How many race conditions does attackers have to win in the following program?
int main() {
struct stat stat1, stat2;
int fd1, fd2;
if (access("/tmp/XYZ", O_RDWR)) {
fprintf(stderr, "Permission denied\n");
return -1;
}
else fd1 = open("/tmp/XYZ", O_RDWR);
if (access("/tmp/XYZ", O_RDWR)) { '
fprintf(stderr, "Permission denied\n");
return -1;
}
else fd2 = open("/tmp/XYZ", O_RDWR);
// Check whether fd1 and fd2 have the same inode.
fstat(fd1, &stat1);
fstat(fd2, &stat2);
if(stat1.st_ino == stat2.st_ino) {
write_to_file(fd1);
}
else {
fprintf(stderr, "Race condition detected\n");
return -1;
}
return 0;
}
In: Computer Science
Without using extra structures, write a recursive method
recursivenumberOfNonZeros (Queue<Integer> q)in Test class (in
stacks_queues package) that receives a queue contains integer
objects and return total number of non zeros in this queue. Then
don’t forget to test the method in the main.
Note: Make sure not to change the order of the other values in
queue after calling the method.
In: Computer Science
Part 2
BeerBatch Class
/**
* A class to model an item (or set of items) in an
* auction: a batch.
*/
public class BeerBatch
{
// A unique identifying number.
private final int number;
// A description of the batch.
private String description;
// The current highest offer for this
batch.
private Offer highestOffer;
/**
* Construct a BeerBatch, setting its
number and description.
* @param number The batch number.
* @param description A description of this
batch.
*/
public BeerBatch(int number, String
description)
{
this.number =
number;
this.description =
description;
this.highestOffer =
null;
}
/**
* Attempt an offer for this batch. A
successful offer
* must have a value higher than any
existing offer.
* @param offer A new offer.
* @return true if successful, false
otherwise
*/
public boolean bidFor(Offer offer)
{
if(highestOffer == null)
{
// There is no previous bid.
highestOffer = offer;
return true;
}
else
if(offer.getAmount() > highestOffer.getAmount()) {
// The bid is better than the previous one.
highestOffer = offer;
return true;
}
else {
// The bid is not better.
return false;
}
}
/**
* @return A string representation of this
batch's details.
*/
public String batchDetail()
{
return "TO DO";
}
/**
* @return The batch's number.
*/
public int getNumber()
{
return number;
}
/**
* @return The batch's description.
*/
public String getDescription()
{
return
description;
}
/**
* @return The highest offer for this
lot.
* This could be
null if there is
* no current
bid.
*/
public Offer getHighestOffer()
{
return
highestOffer;
}
}
Offer Class
/**
* A class that models an offer.
* It contains a reference to the Person bidding and the amount of
the offer.
*/
public class Offer
{
// The person making the bid.
private final Bidder bidder;
// The amount of the offer.
private final int amount;
/**
* Create an offer.
* @param bidder Who is bidding for the
batch.
* @param x The amount of the offer.
*/
public Offer(int x, Bidder b)
{
this.bidder = b;
this.amount = x;
}
/**
* @return The bidder.
*/
public Bidder getBidder()
{
return bidder;
}
/**
* @return The amount of the offer.
*/
public int getAmount()
{
return amount;
}
}
In: Computer Science
Create the following class to represent the sprite objects in the game.
|
Sprite |
|
|
+ Sprite (String); + Sprite (String, int, int); + setName (String): void + setX(int): void + setY(int): void + getName (): String + getX (): int + getY (): int + collide (Sprite): boolean + toString (): String |
Create ten (10) game objects as Sprite type and stored in an array. All the games objects location (x & y) must be set in range 1 to 800 randomly.
The collide method is a method to test the collision between the current sprite with another sprite (from parameter). This method will check the distance in between two sprites based on the current x and y location using Pythagoras theorem. If the distance of 2 objects is less than 10, then the method will return true. Otherwise false will be returned.
Create a driver class called TestSprite which will:
In: Computer Science
Java
Write a valid Java method called printReverse that takes a String as a parameter and prints out the reverse of the String. Your method should not return anything. Make sure you use the appropriate return type.
In: Computer Science
In: Computer Science
|
Northern |
Central |
Southern |
|
|
Northern |
$5,000.00 |
$7,000.00 |
$10,000.00 |
|
Central |
$7,000.00 |
$5,000.00 |
$6,000.00 |
|
Southern |
$10,000.00 |
$6,000.00 |
$5,000.00 |
|
Shortage |
$6,000.00 |
$5,500.00 |
$9,000.00 |
How should California’s water be distributed to minimize the sum of shipping and shortage costs and what is the total cost?
In: Computer Science
source: /** * A class to model an item (or set of items) in an * auction: a batch. */ public class BeerBatch { // A unique identifying number. private final int number; // A description of the batch. private String description; // The current highest offer for this batch. private Offer highestOffer; /** * Construct a BeerBatch, setting its number and description. * @param number The batch number. * @param description A description of this batch. */ public BeerBatch(int number, String description) { this.number = number; this.description = description; this.highestOffer = null; } /** * Attempt an offer for this batch. A successful offer * must have a value higher than any existing offer. * @param offer A new offer. * @return true if successful, false otherwise */ public boolean bidFor(Offer offer) { if(highestOffer == null) { // There is no previous bid. highestOffer = offer; return true; } else if(offer.getAmount() > highestOffer.getAmount()) { // The bid is better than the previous one. highestOffer = offer; return true; } else { // The bid is not better. return false; } } /** * @return A string representation of this batch's details. */ public String batchDetail() { return "TO DO"; } /** * @return The batch's number. */ public int getNumber() { return number; } /** * @return The batch's description. */ public String getDescription() { return description; } /** * @return The highest offer for this lot. * This could be null if there is * no current bid. */ public Offer getHighestOffer() { return highestOffer; } } Question: Implement the method batchDetail() in the BeerBatch class. Below you see the details of the first three batches created in the BearAuction constructor. For your string use the same format as below! 1: 1892 Traditional Bid: 14 by Juliet (female, 27) 2: Iceberg Lager No bid 3: Rhinegold Altbier Bid: 17 by William (male, 22).
In: Computer Science
In: Computer Science
I have to create a light dispersion prism animation in Matlab. I need a well-explained Matlab script which works.
In: Computer Science
1) What is the member initializer list used for? Give a code example of using one
2) Give two examples of when the copy constructor is called by the “compiler”.
3) What actions should be done in the destructor function? Give an example function header for the destructor for the Jedi class. When is the destructor called?
Thank you!
In: Computer Science
Do you consider what Google Marketing Platform does for its clients to be a good business strategy on behalf of the clients, or an invasion of privacy on behalf of consumers who frequent the clients' sites and use their apps? Why, or why not? Regarding consumer behavior, are you an experiential or utilitarian online shopper? Why so?
In: Computer Science
this homework should be done in 30 minute
Draw a Use Case Diagram based on the following narrative:
A company called Joyful Foods is introducing a system that allows customers to make food orders through their mobile phones. Customers can register new accounts, which include validating credit card information. They can view the menus of various restaurants and they will have the option of checking the restaurants' ratings while doing so. Customers also can rate any restaurant with a rating from 1-10. When they make food orders, they will have the option of paying online. Company staff will have to confirm food orders with the customers by calling them to make sure that the orders are valid. Furthermore, the company hired drivers will be able to view order information to see the location of the customers. Lastly, managers will be able to grant monthly rewards for drivers after checking their performance.
In: Computer Science