logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Garard BerwickkCriminology
(5/5)

980 Answers

Hire Me
expert
Henry BehrensAccounting
(5/5)

541 Answers

Hire Me
expert
Jim TavareLaw
(5/5)

537 Answers

Hire Me
expert
Marilyn DruettCriminology
(5/5)

877 Answers

Hire Me
Java Programming

The electric power grid is the network infrastructure responsible for the generation and trans- mission of electricity. We have three types of elements in a power grid:

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

1             Introduction

The electric power grid is the network infrastructure responsible for the generation and trans- mission of electricity. We have three types of elements in a power grid:

A generator: this is a station that generates electricity. A generator has a power limit that it cannot exceed.

A transmitter: this is a station that transmits electricity. A transmitter can be connected directly to a generator or to another transmitter. A transmitter has a maximum power that can pass through it.

A consumer: this can be a household, a shop, a factory etc. A consumer can only be attached to a transmitter (not directly to a generator), and no element can be attached to it. A consumer has maximum consumption power that it cannot exceed.

For simplicity, we assume that the power grid can be represented as a general (non-binary) tree. The grid contains only one generator located at the root, whereas consumers are located at leaf nodes. See Figure 1 for an example.

We are interested in the following:

  1. Finding how much power is generated, transmitted or consumed by an This is the total power required by the consumers in the corresponding subtree.

Example 1. In the grid shown in Figure 1: Elements 6 and 9 are consuming 0 power, since there are no consumers attached to them. Element 16 consumes 4, Element 8 consumes 10, and Element 4 consumes 19.

 

  1. Whether there is an overload in the grid. An overload takes place when the power required at an element exceeds its By definition, overloads can only happen at the generator or the transmitters (but not consumers).

Example 2. In the grid shown in Figure 1, the only element that has an overload is Element 4, since it consumes 19, and its limit is 18.

 

In this programming assignment, we will use general trees to represent a power grid.

id: 3 type: Generator

Power:36

 

id: 4

type: Transmitter Power:18

 

id: 5

type: Transmitter Power:18

 

id: 7

type: Transmitter Power:18

 

id: 8

type: Transmitter Power:12

 

id: 6

type: Transmitter Power:12

 

id: 10 type: Consumer

Power:9

 

id: 12 type: Consumer

Power:4

 

id: 16 type: Consumer

Power:4

id: 17 type: Consumer

Power:4

 

id: 13 type: Consumer

Power:3

 

id: 11 type: Consumer

Power:3

 

id: 14 type: Consumer

Power:4

 

id: 9

type: Transmitter Power:12

The enumeration ElemType is defined as follows:

Using these definitions, write the class PowerGridUtils:

public c l a s s Power Grid Utils {

 

//   Return   the   IDs   of   all   elements   in   the   power   grid   pg   in   pre - order.

public s t a t i c Queue < Integer > collect Preorder ( GT < PGElem > pg);

 

//   Searches   the   power   grid   pg   for   the   element   with   ID   id.   If   found ,   it is   made   current   and   true   is   returned ,   otherwise   false   is   returned.

public s t a t i c boolean find ( GT < PGElem > pg , int id);

 

//   Add   the   generator   element   gen   to   the   power   grid   pg.   This   can   only   be done   if   the   grid   is   empty.   If   successful ,   the   method   returns   true.

If   there   is   already   a   generator ,   or   gen   is   not   of   type   Generator , false   is   returned.

public s t a t i c boolean add Generator ( GT < PGElem > pg , PGElem gen );

 

//   Attaches   pgn   to   the   element   id   and   returns   true   if   successful.   Note that   a   consumer   can   only   be   attached   to   a   transmitter ,   and   no element   can   be   be   attached   to   it.   The   tree   must   not   contain   more than   one   generator   located   at   the   root.   If   id   does   not   exist ,   or there   is   already   aelement   with   the   same   ID   as   pgn ,   pgn   is   not attached ,   and   the   method   retrurns   false.

public s t a t i c boolean attach ( GT < PGElem > pg , PGElem pgn , int id);

 

//   Removes   element   by   ID ,   all   corresponding   subtree   is   removed.   If removed ,   true   is   returned ,   false   is   returned   otherwise.

public s t a t i c boolean remove ( GT < PGElem > pg , int id);

 

//   Computes   total   power   that   consumed   by   a   element   ( and   all   its   subtree

).   If   id   is   incorrect ,   -1   is   returned.

public s t a t i c double total Power ( GT < PGElem > pg , int id);

 

//   Checks   if   the   power   grid   contains   an   overload.   The   method   returns the   ID   of   the   first   element   preorder   that   has   an   overload   and   -1   if there   is   no   overload.

public s t a t i c int find Overload ( GT < PGElem > pg);

}

 

4           Deliverable and rules

You must deliver:

  1. Source code submission to Web-CAT. You have to upload the following class in a zipped file:

    • java

    • java

Notice that you should not upload the interfaces and classes given to you.

The submission deadline is: 26/11/2019.

You have to read and follow the following rules:

  1. The specification given in the assignment (class and interface names, and method signatures) must not be Any change to the specification results in compilation errors and consequently the mark zero.

  2. All data structures used in this assignment must be implemented by the The use of Java collections or any other data structures library is strictly forbidden.

  3. This assignment is an individual Sharing code with other students will result in harsh penalties.

  4. Posting the code of the assignment or a link to it on public servers, social platforms or any communication media including but not limited to Facebook, Twitter or WhatsApp will result in disciplinary measures against any involved

  5. The submitted software will be evaluated automatically using Web-Cat.

  6. All submitted code will be automatically checked for similarity, and if plagiarism is con- firmed penalties will

  7. You may be selected for discussing your code with an examiner at the discretion of the teaching If the examiner concludes plagiarism has taken place, penalties will apply.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme