Questions
Part 2 BeerBatch Class /** * A class to model an item (or set of items)...

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 Name: String x:...

Create the following class to represent the sprite objects in the game.

Sprite

  • Name: String
  • x: x location
  • y: y location

      +   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:

  • Display all the game sprite objects with a loop
  • Use the games objects from the array, test all the instance methods.

In: Computer Science

Java Write a valid Java method called printReverse that takes a String as a parameter and...

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

Please find error and fill the blank and send as I can copy and paste like...

Please find error and fill the blank and send as I can copy and paste like file or just codes if you can ?
1)
#include <stdio.h>
#include <stdlib.h>

#define Error( Str ) FatalError( Str )
#define FatalError( Str ) fprintf( stderr, "%s ", Str ), exit( 1 )
2) #include "list.h"
#include <stdlib.h>
#include "fatal.h"

/* Place in the interface file */

int Equal(ElementType x, ElementType y)
{
return x==y;
}
void Print(ElementType x)
{
printf("%2d", x);
}

List
CreateList( void )
{
List L;

L = ________________________________;
if( L == NULL )
Error( "Out of memory!" );
L->Next = NULL;
return L;
}

void
MakeEmpty( List L )
{
Position P, Tmp;

/* 1*/ P = L->Next; /* Header assumed */
/* 2*/ L->Next = NULL;
/* 3*/ while( P != NULL )
{
/* 4*/ Tmp = P->Next;
/* 5*/ free( P );
/* 6*/ P = Tmp;
}
}


/* START: fig3_8.txt */
/* Return true if L is empty */

int
IsEmpty( List L )
{
return L->Next == NULL;
}
/* END */

/* START: fig3_9.txt */
/* Return true if P is the last position in list L */
/* Parameter L is unused in this implementation */

int IsLast( Position P, List L )
{
return P->Next == NULL;
}
/* END */

/* START: fig3_10.txt */
/* Return Position of X in L; NULL if not found */

Position
Find( ElementType X, List L )
{
Position P;

/* 1*/ P = L->Next;
/* 2*/ while( P != NULL && !Equal(P->Element, X))
/* 3*/ P = P->Next;

/* 4*/ return _______;
}
/* END */

/* START: fig3_11.txt */
/* Delete (after legal position P) */
/* Assume use of a header node */
void
Delete(List L, Position P )
{
Position TmpCell;

TmpCell = P->Next;
P->Next = TmpCell->Next; /* Bypass deleted cell */
free( TmpCell );
}

/* END */

/* START: fig3_12.txt */
/* If X is not found, then Next field of returned value is NULL */
/* Assumes a header */

Position
FindPrevious( ElementType X, List L )
{
Position P;

/* 1*/ P = L;
/* 2*/ while( P->Next != NULL && !Equal(P->Next->Element, X) )
/* 3*/ P = P->Next;

/* 4*/ return P;
}
/* END */

/* START: fig3_13.txt */
/* Insert (after legal position P) */
/* Header implementation assumed */
/* Parameter L is unused in this implementation */

void
Insert( ElementType X, List L, Position P )
{
Position TmpCell;

/* 1*/ TmpCell = (Position)malloc( sizeof( struct Node ) );
/* 2*/ if( TmpCell == NULL )
/* 3*/ Error( "Out of space!!!" );

/* 4*/ TmpCell->Element = X;
/* 5*/ ____________________;
/* 6*/ P->Next = TmpCell;
}
/* END */

/* START: fig3_15.txt */
/* Correct DeleteList algorithm */

void
DeleteList( List L )
{
PtrToNode P, Tmp;

P = L;
while( P != NULL )
{
Tmp = P->Next;
free( P );
____________;
}
}
/* END */

Position
Header( List L )
{
return ________;
}

Position
First( List L )
{
return _________;
}

Position
Advance( Position P )
{
return ___________;
}

ElementType
Retrieve( Position P )
{
return ____________;
}

void Modify( ElementType X, Position P )
{
P->Element = X;
}

void PrintList(List L)
{
Position pL;
ElementType e;

pL = First(L);
while (pL) {
e = Retrieve(pL);
Print(e);
pL = Advance(pL);
}
printf(" ");
}

3)

#ifndef _List_H
#define _List_H



typedef int ElementType;
struct Node {
ElementType Element;
struct Node *Next;
};
typedef struct Node
*PtrToNode, *List, *Position;


void MakeEmpty( List L );
List CreateList( void );
int IsEmpty( List L );
int IsLast( Position P, List L );
Position Find( ElementType X, List L );
void Delete( List L, Position P );
Position FindPrevious( ElementType X, List L );
void Insert( ElementType X, List L, Position P );
void DeleteList( List L );
Position Header( List L );
Position First( List L );
Position Advance( Position P );
ElementType Retrieve( Position P );
void Modify( ElementType X, Position P );
void PrintList(List L);

#endif /* _List_H */
/* END */

4)

#include "stdio.h"
#include "list.h"
#include "fatal.h"


List Union(List A, List B) {
List C;
Position pA, pB, pC;
ElementType e;

C = CreateList();
pC = Header(C);

pA = First(A);
while (pA) {
e = Retrieve(pA);
Insert(e, C, pC);
pA = Advance(pA);
}

pB = First(B);
while (pB) {
e = Retrieve(pB);
if (!Find(e, A))
Insert(e, C, pC);
pB = Advance(pB);
}
return C;
}


int main() {
List A, B, C;
int j;


A = CreateList(); B = CreateList();

printf("Please input set A(finished with -1): ");
scanf("%d", &j);
while (j != -1){
Insert(j, A, Header(A));
scanf("%d", &j);
}
printf("A:"); PrintList(A);

printf("Please input set B(finished with -1): ");
scanf("%d", &j);
while (j != -1){
Insert(j, B, Header(B));
scanf("%d", &j);
}
printf("B:"); PrintList(B);

C = Union(A, B);
printf("C:"); PrintList(C);

DeleteList(A); DeleteList(B); DeleteList(C);

return 1;
}

In: Computer Science

Suppose that each day, Northern, Central, and Southern California each use 100 billion gallons of water....

  1. Suppose that each day, Northern, Central, and Southern California each use 100 billion gallons of water. Also assume that Northern California and Central California have available 120 billion gallons of water, whereas Southern California has 40 billion gallons of water available. The cost of shipping 1 billion gallons of water between the three regions is as follows. Also, you will not be able to meet all the demand for water, so assume that each billion gallons of unmet demand incurs the following shortage costs:

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 *...

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

Explain white labeling and drop shipping along with the challenges

Explain white labeling and drop shipping along with the challenges

In: Computer Science

I have to create a light dispersion prism animation in Matlab. I need a well-explained Matlab...

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...

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...

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...

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

If I want to show an exception in JAVA GUI that checks if the date format...

If I want to show an exception in JAVA GUI that checks if the date format is correct or the date doesn't exist, and if no input is put in how do I do that. For example if the date format should be 01-11-2020, and user inputs 11/01/2020 inside the jTextField it will show an error exception message that format is wrong, and if the user inputs an invalid date, it will print that the date is invlaid, and if the user puts no value inside the text box, it willl print an exception message that there needs to be a value.

Please help.

In: Computer Science

Complete the following Java program to, using BigDecimal, calculate and display the radius of the circle...

  1. Complete the following Java program to, using BigDecimal, calculate and display the radius of the circle whose diameter is stored in the variable diameter.  The radius is calculated as half of the diameter. For example, since diameter is 7.5, the program should calculate and display the radius like this:  (2 points)   (CLO 1)

package q1;

import java.math.BigDecimal;

public class Q1 {

    public static void main(String[] args) {

        float diameter=7.5f;

        

    

        

}

}

                                            Radius = 3.75

  1. Consider the following Java program and then answer the questions that follow.  (CLO 4)

Output:

public class TestInheritance{

            public static void main(String args[]){  

            Dog d=new Dog();

            d.eat();    

            d.bark();  

           }

  }

class Animal{  

    void eat()  {System.out.print("eating...");}  

}  

  class Dog __________ Animal {  

        void bark()  {System.out.println("barking...");}  

        void eat() {

              super.eat();

              System.out.println("only dog food");

         }

  }  

  

  

4.1 Fill in the missing keyword in the class Dog declaration to make it a subclass of   Animal.  (0.5 points)

4.2 In the box provided above, show the output of the program. (2 points)

  1. Consider the earnings method of the subclass BasePlusCommissionEmployee, given below, then answer the question that follows:  (2.5 points)  (CLO 4)

  public double earnings()

   {

      return getBaseSalary() + Super.earnings();

   }    

  Find and fix the syntax error that is likely to be generated in the above method.

In: Computer Science

Question 2 (a). Kotulas Company Ltd has, over the last decade, been using a web-based Sales...


Question 2
(a). Kotulas Company Ltd has, over the last decade, been
using a web-based Sales Order and Procurement System
(SOPS) for its operations.  
(i). Describe categories of users of this company’s
AN[7 marks]
SOPS; and provide practical examples of what each category of users may use this system for, and why?
(ii). Discuss factors that, in your opinion, may cause this company to consider developing a new (or upgrading AN[8 marks] its existing) SOPS.       

(b). You have been using AIT’s LEMASS for more than a year now.
(i).. Describe five functional requirements and five non

functional requirements that LEMASS has EV[5 marks] fulfilled.
(ii). Describe practical problems you have identified with LEMASS; and explain how each of those problems can be
resolved.

PLEASE HELP ME SOLVE THIS QUESTIONS. WOULD LOVE IT TYPED.

In: Computer Science

What is the difference between MDF and LDF files in Microsoft SQL Server? give examples.

What is the difference between MDF and LDF files in Microsoft SQL Server? give examples.

In: Computer Science