1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
beks73 [17]
4 years ago
6

C#

Computers and Technology
1 answer:
ad-work [718]4 years ago
6 0

Answer:

Check the explanation

Explanation:

class AssemblyLine

{

// Builder uses a complex series of steps

//

public void Assemble(SandwichBuilder sandwichBuilder)

{

sandwichBuilder.AddMeats();

sandwichBuilder.AddSandwich Number();

sandwichBuilder.AddPrice();

sandwichBuilder.AddCalories();

}

}

class Sandwich

{

private string _sandwichType;

private Dictionary<string, string> _ingredients = new Dictionary<string, string>();

// Constructor

public Sandwich(string sandwichType)

{

this._sandwichType = sandwichType;

}

// Indexer

public string this[string key]

{

get { return _ingredients[key]; }

set { _ingredients[key] = value; }

}

public void Show()

{

Console.WriteLine("\n---------------------------");

Console.WriteLine("Sandwich: {0}", _sandwichType);

Console.WriteLine(" Meat: {0}", _ingredients["meat"]);

Console.WriteLine("Sandwich Number: {0}", _ingredients["sandwich Number"]);

Console.WriteLine(" Price: {0}", _ingredients["price"]);

Console.WriteLine(" Calories: {0}", _ingredients["calories"]);

}

}

abstract class SandwichBuilder

{

protected Sandwich sandwich;

// Gets sandwich instance

public Sandwich Sandwich

{

get { return sandwich; }

}

// Abstract build methods

public abstract void AddMeats();

public abstract void AddSandwich Number();

public abstract void AddPrice();

public abstract void AddCalories();

}

class TurkeyClub : SandwichBuilder

{

public TurkeyClub()

{

sandwich = new Sandwich("Turkey Club");

}

public override void AddMeats()

{

sandwich["meat"] = "Turkey";

}

public override void AddSandwich Number()

{

sandwich["sandwich Number"] = "10";

}

public override void AddPrice()

{

sandwich["price"] = "50";

}

public override void AddCalories()

{

sandwich["calories"] = "361";

}

}

/// <summary>

/// A ConcreteBuilder class

/// </summary>

class BLT : SandwichBuilder

{

public BLT()

{

sandwich = new Sandwich("BLT");

}

public override void AddMeats()

{

sandwich["meat"] = "Bacon";

}

public override void AddSandwich Number()

{

sandwich["sandwich Number"] = "2";

}

public override void AddPrice()

{

sandwich["price"] = "None";

}

public override void AddCalories()

{

sandwich["calories"] = "none";

}

}

/// <summary>

/// A ConcreteBuilder class

/// </summary>

class HamAndCheese : SandwichBuilder

{

public Ham()

{

sandwich = new Sandwich("Ham ");

}

public override void AddSandwhich Number()

{

sandwich["sandwhich number"] = "1";

}

public override void AddMeats()

{

sandwich["meat"] = "Ham";

}

public override void AddPrice()

{

sandwich["price"] = "None";

}

public override void AddCalories()

{

sandwich["calories"] = "none";

}

}

static void Main(string[] args)

{

SandwichBuilder builder;

// Create shop with sandwich assembly line

AssemblyLine shop = new AssemblyLine();

// Construct and display sandwiches

builder = new Ham();

shop.Assemble(builder);

builder.Sandwich.Show();

builder = new BLT();

shop.Assemble(builder);

builder.Sandwich.Show();

builder = new TurkeyClub();

shop.Assemble(builder);

builder.Sandwich.Show();

// Wait for user

Console.ReadKey();

}

You might be interested in
. Constructors are executed when?
adoni [48]

Answer:

 The constructor are executed when the constructor object are comes in the existence as per the general rule in the computer programming language. The constructor is the special type of the class function that basically perform the initialization of the each object in the computer science.

Then, the constructor initialized actual value of the member of an object are allocated to the given object in the system.  

6 0
3 years ago
If you got band from a local library, what would be the reason for it besides shouting and talking? You're answer has to fit you
VLD [36.1K]

Answer:

I would get a band from the library because I check out ten books and returned them in a week. I also would just be in the library all the time and they would get frustrated. That or I would spend hours talking to a librarian about my favorite books and they would get fed up with me.

4 0
3 years ago
Read 2 more answers
Using the program below, explain what the output will be at LINE A. 1 #include 2#include 3#include 4 5 int value - 128; 6 7 int
slega [8]

Answer:

This is the complete correct program:

#include <stdio.h>

#include<sys/types.h>

#include<unistd.h>

int value = 128;

int main()

{

  pid_t pid;

  pid=fork();

  if (pid==0) /* child process */

  {

  value +=8;

  return 0; }

  else if (pid > 0) {/* parent process */

 wait (NULL);

 printf ("PARENT: value =%d\n" ,value); /* LINEA */

 return 0;

}

}

The output of the LINE A is:

PARENT: value = 128

Explanation:

The fork() function used in the program creates a new process and this process is the child process. The child process is same as the original process having its own address space or memory.

In the child process the value of pid is 0. So the if condition checks if pid==0. Then the child process adds 8 to the value of its variable according to the following statement  

value +=8;

Now the original process has value = 128. In else if part the parents process has the value of pid greater than zero and this portion of the program is of the parent process :

else if (pid > 0)

{ wait (NULL);

printf ("PARENT: value =%d\n" ,value);

return 0; }

So the value 128 is printed at the end in the output.

wait(NULL) is used to wait for the child process to terminate so the parent process waits untill child process completes.

So the conclusion is that even if the value of the variable pid is changed in the child process but it will not affect the value in the variable of the parent process.

5 0
3 years ago
Which one of the following statements is true regarding the fetch-execute cycle? Each step of the fetch-execute cycle is perform
AfilCa [17]

Answer:

The device responsible for performing the fetch-execute cycle is the CPU.

Explanation:

The fetch execution cycle is the way or method the CPU executes instructions given to it. In this process or cycle, the CPU fetches the instruction, then decodes it, executes it, and stores the information in its database.

The CPU executes one instruction at a time.

8 0
4 years ago
I don't understand how to write both. If I repeat the first code but with 3 and 6 it doesn't work.
hram777 [196]

It looks like you need to get both numbers from the input. Try doing something like this:

print(int(input()) + int(input()))

4 0
3 years ago
Other questions:
  • Which is NOT a type of SD card?
    8·2 answers
  • Write a Java program that generates a random number between 0 and 50. Then, the program prompts for guesses until the user is co
    14·1 answer
  • Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the secon
    11·1 answer
  • Which deployment tool will you use to deploy metadata from one organization to another organization?
    6·1 answer
  • Samira recently opened an online potted plant store and needs to promote it. She chose Google Ads because it offers advertisers
    12·2 answers
  • In the function below, use a function from the random module to return a random integer between the given lower_bound and upper_
    10·1 answer
  • Please help me
    7·2 answers
  • Write down the different types of testing with their definition.
    11·1 answer
  • Private void finishMap()
    7·1 answer
  • What is the size of the rc.conf file in bytes
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!