Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I turn this function: private int makeForwardConnections(Model model) { int w = model.width(), h = model.height(); int result; result = 1; for (Sq

How do I turn this function:

private int makeForwardConnections(Model model) { int w = model.width(), h = model.height(); int result; result = 1; for (Sq sq : model) { Sq found; found = null; int nFound; nFound = 0; if (sq.successor() == null && sq.direction() != 0) { PlaceList successors = sq.successors(); if (successors == null) { continue; } for (Place p : successors) { if (sq.connectable(model.get(p))) { ++nFound; found = model.get(p); } } if (sq.sequenceNum() != 0) { for (Place p : successors) { Sq next = model.get(p); if (sq.connectable(next) && next.sequenceNum() != 0) { nFound = 1; found = next; break; } } } if (nFound == 0) { return 0; } else if (nFound == 1) { sq.connect(found); result = 2; } } } return result; }

into two separate functions? :

static Sq findUniqueSuccessor(Model model, Sq start) {

// Your Code Here

static boolean makeForwardConnections(Model model) { int w = model.width(), h = model.height(); boolean result; result = false; for (Sq sq : model) { if (sq.successor() == null && sq.direction() != 0) { Sq found = findUniqueSuccessor(model, sq); if (found != null) { sq.connect(found); result = true; } } } return result; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

How is the scope of a F# let construct terminated?

Answered: 1 week ago