SlideShare a Scribd company logo
For any help regarding Software Construction Assignment Help
Visit :- https://www.programminghomeworkhelp.com/ ,
Email :- support@programminghomeworkhelp.com or
call us at :- +1 678 648 4277
Programming Homework Help
(a)Which of thefollowing mustbe trueof anunderdeterminedfunction specification?(choose all that apply)
A. An underdeterminedspecmeanstheimplementationisunwritten.
B. An underdeterminedspecmeanstheimplementationisnondeterministic.
C. An underdeterminedspecallows multiple valid outputsfor some input.
D.An underdeterminedspecallows multiple valid inputsthatgive some output.
(b) After thefollowing code is executed, whatis thevalue of arrayarr? (choose one answer)
final String[] arr = new String[2]; String s = "6.005";
arr[0] = s;
s = "is";
arr[1] = s; String t = arr[0]; t = "fun";
A. [ "is", "is" ]
B. [ "6.005", "is" ]
C. [ "fun", "is" ]
D. none of the above
(c) The line of Javacode String t = arr[0]; involves... (choose all that apply)
A. assignment
B. equivalence relation
C. mutation
D.static typing
Programming Homework Help
(d)Alyssa P.Hackeris designing animmutabletype torepresentusersinhercomputersystem. The User’s login
nameis stored as:
private final String kerberos;
She definestwo User objects asequalif theirlogin namesarethesame,ignoring case:
@Override public boolean equals(Object other) { if (!(other instanceof
User)) { return false; } User that = (User)other;
return this.kerberos.equalsIgnoreCase(that.kerberos);
}
@Override public int hashCode() { /* TODO */ }
Which of thefollowing implementations of hashCode() would bevalid, satisfyingtheObject contract? (choose
all that apply)
A.return 31;
B.return this.kerberos.hashCode();
C.return this.kerberos.toLowerCase().hashCode();
D.return this.kerberos.toUpperCase().hashCode();
(e)If thecode inanswerchoice (A) aboveappearedinyour 6.005code review assignment,which of the following
commentswould beappropriatecriticisms? (choose all that apply)
A. The code isn’t DRY.
B. The code usesmagic numbers.
C. The code exposes User’s representation.
D.The code is unnecessary,we don’t needtooverridehashCode if we only returna constant.
Programming Homework Help
Problem 2 (Specifications)
A tetromino is a shape made out of four adjacent squares. These shapes are most famous from the game
Tetris where the player must rotate and translate falling tetrominoes in order to fit them together. There are
sevenpossible tetrominoesthatlie onthe2D plane,andeachis identifiedby aletter it lookslike:
I O T J L S Z
Define atetromino shape letter asoneof thesevenletters IO T JL S Z, eitherupper-orlowercase.
Tetrominoesmayberotatedby 0,90,180, or270 degrees.
A diagram of all seven tetrominoes in all four orientations is on the last page of this quiz.
Let’s defineanabstractdatatype torepresenttetrominoes:
public class Tetromino {
// determine if a character is a valid tetromino shape letter
public static boolean isValidShape(char shape) { ... }
// make a new tetromino
public Tetromino(char shapeLetter, int rotationDegrees) { ... }
// rotate this tetromino
public void rotateClockwise() { ... }
// get the shape of this tetromino
public char shape() { ... }
}
(a) Fill inthistable with informationabouttheoperationsof Tetromino. The
answersfor isValidShape arealready given.
Programming Homework Help
operation type signature
classify thetypeof
ADT operation
Java implementation
strategy
isValidShape char→ boolean
not applicable static method
Tetromino
rotateClockwise
shape
Programming Homework Help
(b) Consider thesedifferent specificationsfor theisValidShapefunction:
public static boolean isValidShape(char shape)
/**
* @param shape any character
* @return true iff shape is a lowercase tetromino shape letter
*/
/**
* @param shape an English alphabetic character
* @return true iff shape is a lowercase tetromino shape letter
*/
/**
* @param shape a lowercase tetromino shape letter
* @return true
*/
SpecA
SpecB
SpecC
Comparethesespecifications.Foreachpairbelow, circle one correct option andwrite write a brief
explanation tocompletethesentence.
A vs. B:
equivalent to
weakerthan
strongerthan
incomparable to
SpecA is specB because
B vs. C:
equivalent to
weakerthan
strongerthan
incomparable to
SpecB is
specC because
Programming Homework Help
Problem 3 (AFs & RIs)
Hereis animplementationof theTetrominoADT.
/** A rotatable tetromino. */
public class Tetromino {
// ... static method isValidShape ...
private final char shape;
private int rotation;
// Abstraction function
// TODO
// Representation invariant
// TODO
// Safety from rep exposure
// TODO
/**
* Make a new Tetromino with the given shape and rotation.
* @param shapeLetter uppercase tetromino shape letter
* @param rotationDegrees clockwise rotation in degrees,
* must be 0, 90, 180, or 270
Programming Homework Help
*/
public Tetromino(char shapeLetter, int rotationDegrees) {
this.shape = shapeLetter;
this.rotation = rotationDegrees / 90;
}
/**
* TODO
*/
public void rotateClockwise() { rotation = (rotation + 1) %
4;
}
/**
* @return shape of this tetromino: ’I’ ’O’ ’T’ ’J’ ’L’ ’S’ or ’Z’
*/
public char shape() {
return shape;
}
@Override
public String toString() {
return shape + "-shape@" + rotation * 90 + "deg";
}
}
Programming Homework Help
(a) For each of the statements below, say whether it should be included in the internal documentation of
Tetromino by writing:
AF if the statement belongs in the abstraction function
RI ... the rep invariant
EXP ... the argument that type has no rep exposure
NONE if it should not be included in any of those
You should include in the AF, RI, or EXP all good statements that are compatible with the code and specs on
the previous page.
Do not include statements that are not compatible with the code and specs.
shape is private and an immutable value
rotation is private and an immutable value
this Tetromino is never returned to clients
shape is an uppercase tetromino shape letter
shapeLetter is an uppercase tetromino shape letter
the tetromino has the shape given by shape
rotation = 0
the tetromino is rotated clockwise by rotation
Programming Homework Help
the tetromino is rotated clockwise rotation times 90 degrees
0 <= rotation < 4
0 <= rotation < 360
rotation is one of { 0, 90, 180, 270 }
Consider thesedifferent specificationsfor therotateClockwisemethod:
public void rotateClockwise()
Programming Homework Help
Foreachpossiblespecificationbelow, write a one-sentence code review comment that identifies themost
serious problem with the spec.
(b) /**
* Update this tetromino’s rotation number to add 1, mod 4.
*/
Comment:
(c) /**
* @return this tetromino rotated by 90 degrees clockwise
*/
Comment:
(d) /**
* Rotate this tetromino (does not otherwise modify the tetromino).
*/
Comment:
Programming Homework Help
Problem 4
Let’s consider the problem of packing tetrominoes into a rectangle by rotating and translating them in the 2D
plane. For example, here are tetrominoes I, L, & Z packed into a 5 × 4 rectangle, and a 7 × 2 rectangle:
For those three tetrominoes, the minimum area they can be packed into is 7 × 2 = 14 squares.
(a) /**
* @param shapes string of tetromino shape letters
* @return a 2-element list representing a minimum-area rectangle into which
* the tetrominoes given by shapes can be packed
* (for example, pack("ILZ") might return the list [ 2, 7 ])
*/
public static List pack(String shapes) { ... }
Start writing a black box testing strategy for pack(..) by giving one good partitioning for input shapes:
For each of the test cases below, in the first box write YES or NO in the first box to say whether the
test valid or not. If the test is not valid, write a one-sentence reason why not. We’ll use Python’s
syntax to represent lists for brevity
Programming Homework Help
Problem 5 (Rep Exposure) . Let’s define a mutable abstract data type TetrominoGrid to represent tetrominoes arranged
on a fixed-size grid, where every tetromino fits on the grid and none of the tetrominoes overlap. For example:
Programming Homework Help
On the next page is an implementation of TetrominoGrid. In its rep, TetrominoGrid stores the location of
each tetromino using a map from integers to tetrominoes. The integer keys are square numbers: Each square
in the grid is numbered starting from 0 in the upper-left corner.
On a grid of width width, square at row row and column col is numbered row × width + col. For example,
here’s how our type would represent the example above:
width = 5, height = 4
tetrominoLocations = {
0: (Tetromino: I-shape rotated 0 degrees),
3: (Tetromino: L-shape rotated 0 degrees),
6: (Tetromino: Z-shape rotated 90 degrees)
}
The TetrominoGrid ADT is implemented using the same mutable Tetromino ADT from previous questions.
(a) Identify all instances of rep exposure in TetrominoGrid on the next page. For each one, write:
1. the line number most directly responsible for the problem,
2. at most one-sentence description of the rep exposure, and
3. at most one-sentence description of how to fix the problem, or a single corrected line
of code.
There may be more boxes than you need.
Programming Homework Help
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
You may detach this page from your quiz, but you must write your name above and turn in all pages.
/**
* Mutable type representing a fixed-size grid with a valid arrangement of
* tetrominoes: every tetromino fits on the grid without overlapping.
*/
public class TetrominoGrid {
1) private final int width;
2) private final int height;
3) public final Map<Integer, Tetromino> tetrominoLocations;
Programming Homework Help
// create a new grid and try to add some tetrominoes
public TetrominoGrid(int width, int height, List<Tetromino> initial) {
this.width = width;
this.height = height; this.tetrominoLocations = new
HashMap<>(); for (Tetromino tetromino : initial) {
this.add(tetromino.shape());
}
}
4)
5)
6)
7)
// get the tetromino whose upper-left corner is the given square
public Tetromino getTetrimino(int row, int col) {
return tetrominoLocations.get(row * width + col);
}
8)
// return a list of all tetriminos currenty on the grid
public List<Tetromino> getTetriminosOnBoard() {
List<Tetromino> tetrominoes = new ArrayList<>();
for (Tetromino tetromino : tetrominoLocations.values()) {
tetrominoes.add(tetromino);
}
return Collections.unmodifiableList(tetrominoes);
}
9)
10)
11)
// try to add a tetromino to the grid, if it can fit without overlap
public boolean add(char shape) {
boolean canBePlaced = false; // can we fit the tetromino anywhere?
int topLeft = -1;
}
12)
13)
14)
15)
Programming Homework Help
int rotation = 0;
// ... code to check whether the new tetromino fits and doesn’t
overlap ...
// ... updates the values of the local variables accordingly ...
if (canBePlaced) {
tetrominoLocations.put(topLeft, new Tetromino(shape,
rotation));
}
return canBePlaced;
16)
// ... other operations ...
}
You may detach this page from your quiz, but you must write your name above and turn in all pages.
Programming Homework Help
Programming Homework Help
Problem 1 (Multiple Choice)
(a)Which of the following must be true of an underdetermined function specification? (choose all that apply)
A.An underdetermined spec means the implementation is unwritten.
B. An underdetermined spec means the implementation is nondeterministic.
C. An underdetermined spec allows multiple valid outputs for some input.
D.An underdetermined spec allows multiple valid inputs that give some output.
Solution. C. None of the other options must be true. □
(b) After the following code is executed, what is the value of array arr? (choose one answer)
final String[] arr = new String[2]; String s = "6.005";
arr[0] = s;
s = "is";
arr[1] = s; String t = arr[0]; t =
"fun";
A. [ "is", "is" ]
B. [ "6.005", "is" ]
C. [ "fun", "is" ]
D. none of the above
Solution. B. The reassignment of sto "is"or tto "fun"do not affect arr[0].
□
Programming Homework Help
(c) The line of Java code String t = arr[0]; involves... (choose all that apply)
A.assignment
B. equivalence relation
C.mutation
D.static typing
Solution. A, D. This line assigns to t, which has static type String. □
(d) Alyssa P. Hacker is designing an immutable type to represent users in her computer system. The User’s
login name is stored as:
private final String kerberos;
She defines two Userobjects as equal if their login names are the same, ignoring case:
@Override public boolean equals(Object other) { if (!(other
instanceof User)) { return false; } User that = (User)other;
return this.kerberos.equalsIgnoreCase(that.kerberos);
}
Programming Homework Help
@Override public int hashCode() { /* TODO */ }
Which of the following implementations of hashCode() would be valid, satisfying the Object contract?
(choose all that apply)
A.return 31;
B.return this.kerberos.hashCode();
C.return this.kerberos.toLowerCase().hashCode();
D.return this.kerberos.toUpperCase().hashCode();
Solution. A, C, D.
A is correct, although not necessarily a good hash function.
C and D are correct because Strings that are equal ignoring case will have the same value for both
toLowerCase()and toUpperCase().
B is incorrect because two Users with with login names that differ only in case will have different hash
codes even though the Userobjects are equal. □
(e)If the code in answer choice (A) above appeared in your 6.005 code review assignment, which of the
following comments would be appropriate criticisms? (choose all that apply)
A.The code isn’t DRY.
B.The code uses magic numbers.
C.The code exposes User’s representation.
D.The code is unnecessary, we don’t need to override hashCodeif we only return a constant.
Solution. B. 31 is a magic number.
□
Problem 2 (Specifications)
A tetromino is a shape made out of four adjacent squares. These shapes are most famous from the game
Tetris where the player must rotate and translate falling tetrominoes in order to fit them together. There are
seven possible tetrominoes that lie on the 2D plane, and each is identified by a letter it looks like:
Programming Homework Help
I O T J L S Z
Define a tetromino shape letter as one of the seven letters I O T J L S Z, either upper- or lowercase.
Tetrominoes may be rotated by 0, 90, 180, or 270 degrees.
A diagram of all seven tetrominoes in all four orientations is on the last page of this quiz.
Let’s define an abstract data type to represent tetrominoes:
public class Tetromino {
// determine if a character is a valid tetromino shape letter
public static boolean isValidShape(char shape) { ... }
// make a new tetromino
public Tetromino(char shapeLetter, int rotationDegrees) { ... }
// rotate this tetromino
public void rotateClockwise() { ... }
// get the shape of this tetromino
public char shape() { ... }
}
(a) Fill in this table with information about the operations of Tetromino. The
answers for isValidShapeare already given.
Programming Homework Help
operation type signature
classify the type of
ADT operation
Java implementation
strategy
isValidShape char→ boolean
not applicable static method
Tetromino char×int→Tetromino
creator constructor
rotateClockwise Tetromino→ void
mutator instance method
shape Tetromino→ char observer instance method
(b) Consider these different specifications for the isValidShapefunction:
public static boolean isValidShape(char shape)
/**
* @param shape any character
* @return true iff shape is a lowercase tetromino shape letter
*/
/**
* @param shape an English alphabetic character
* @return true iff shape is a lowercase tetromino shape letter
*/
SpecA
Spec B
Programming Homework Help
Compare these specifications. For each pair below, circle one correct option and write write a brief explanation to
complete the sentence.
Solution. Spec A is stronger than spec B because its precondition is weaker and its postcondition is the same.
Solution. Spec B is stronger than spec C because it has a weaker precondition, and it satisfies C’s postcondition for any
input that satisfies C’s precondition.
Problem 3 (AFs & RIs)
Here is an implementation of the Tetromino ADT.
/** A rotatable tetromino. */
public class Tetromino {
Programming Homework Help
// ... static method isValidShape ...
private final char shape;
private int rotation;
// Abstraction function
// TODO // Representation invariant
// TODO // Safety from rep exposure
// TODO
public Tetromino(char shapeLetter, int rotationDegrees) {
this.shape = shapeLetter;
this.rotation = rotationDegrees / 90;
Programming Homework Help
(a) For each of the statements below, say whether it should be included in the internal documentation of Tetromino by
writing:
AF if the statement belongs in the abstraction function
RI ... the rep invariant
EXP ... the argument that type has no rep exposure
NONE if it should not be included in any of those
You should include in the AF, RI, or EXP all good statements that are compatible with the code and specs on the
previous page.
Do not include statements that are not compatible with the code and specs.
shape is private and an immutable value
rotation is private and an immutable value
this Tetromino is never returned to clients
shape is an uppercase tetromino shape letter
shapeLetter is an uppercase tetromino shape letter
the tetromino has the shape given by shape
rotation = 0
the tetromino is rotated clockwise by rotation
the tetromino is rotated clockwise rotation times 90 degrees
0 <= rotation < 4
0 <= rotation < 360
rotation is one of { 0, 90, 180, 270 }
Programming Homework Help
Solution.
EXP EXP
NONE (doesn’t make sense)
RI
NONE (part of the precondition of the constructor)
AF NONE NONE
AF (see e.g. toString)
RI (established by constructor, maintained by rotateClockwise)
NONE NONE
□
Consider these different specifications for the rotateClockwisemethod:
public void rotateClockwise()
For each possible specification below, write a one-sentence code review comment that identifies the most
serious problem with the spec.
(b) /**
* Update this tetromino’s rotation number to add 1, mod 4.
*/
Comment:
Solution. The specification must be abstract, it should not talk about the representation.
The specification should be declarative, not operational.
□
Programming Homework Help
(c) /**
* @return this tetromino rotated by 90 degrees clockwise
*/
Comment:
Solution. The specification, which says a Tetrominois returned, does not agree with return type void.
□
(d) /**
* Rotate this tetromino (does not otherwise modify the tetromino).
*/
Comment:
Programming Homework Help
Solution. This specification is too weak, it does not specify the amount of rotation. □
Problem 4
Let’s consider the problem of packing tetrominoes into a rectangle by rotating and translating
them in the 2D plane. For example, here are tetrominoes I, L, & Z packed into a 5 × 4 rectangle,
and a 7 × 2 rectangle:
Start writing a black box testing strategy for pack(..) by giving one good partitioning for input shapes: For each of
the test cases below, in the first box write YES or NO in the first box to say whether the test valid or not. If the test
is not valid, write a one-sentence reason why not. We’ll use Python’s syntax to represent lists for brevity.
Programming Homework Help
(b) shapes = "X"
rectangle = [ 0, 0 ]
Valid? Reason if invalid:
Solution. Invalid: shape X violates the precondition
(c) shapes = "I"
rectangle = [ 1, 4 ]
Valid? Reason if invalid:
Solution. Invalid: rectangle [ 4, 1 ] is also allowed by the
postcondition.
d) shapes = "LO“
rectangle = [ 3, 3 ]
Valid? Reason if invalid:
Solution. Valid.
Problem 5
Let’s define a mutable abstract data type TetrominoGrid to represent tetrominoes arranged on a fixed-size
grid, where every tetromino fits on the grid and none of the tetrominoes overlap. For example:
Programming Homework Help
On the next page is an implementation of TetrominoGrid. In its rep, TetrominoGrid stores the location of
each tetromino using a map from integers to tetrominoes. The integer keys are square numbers:
Each square in the grid is numbered starting from 0 in the upper-left corner
On a grid of width width, square at row row and column col is numbered row × width + col.
For example, here’s how our type would represent the example above:
The TetrominoGrid ADT is implemented using the same mutable Tetromino ADT from previous
questions.
(a) Identify all instances of rep exposure in TetrominoGrid on the next page. For each one, write:
1. the line number most directly responsible for the problem,
2. at most one-sentence description of the rep exposure, and
3. at most one-sentence description of how to fix the problem, or a single corrected line of code.
There may be more boxes than you need.
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
Line #: Explanation:
Programming Homework Help
Solution.
Line 3: tetrominoLocations can be accessed and mutated by clients. It should be private.
Line 8: returns a Tetromino that is in the rep, clients could mutate it and break the rep invariant. Should
return a defensive copy.
Line 11 (or 10): returns an unmodifiable list, but the Tetromino objects are still mutable
parts of the rep. Should return defensive copies.
public class TetrominoGrid {
1) private final int width;
2) private final int height;
3) public final Map<Integer, Tetromino> tetrominoLocations;
// create a new grid and try to add some tetrominoes
public TetrominoGrid(int width, int height, List<Tetromino> initial) {
this.width = width;
this.height = height; this.tetrominoLocations = new
HashMap<>(); for (Tetromino tetromino : initial) {
this.add(tetromino.shape());
}
}
4)
5)
6)
7)
Programming Homework Help
// get the tetromino whose upper-left corner is the given square
public Tetromino getTetrimino(int row, int col) {
return tetrominoLocations.get(row * width + col);
}
8)
// return a list of all tetriminos currenty on the grid
public List<Tetromino> getTetriminosOnBoard() {
List<Tetromino> tetrominoes = new ArrayList<>();
for (Tetromino tetromino : tetrominoLocations.values()) {
tetrominoes.add(tetromino);
}
return Collections.unmodifiableList(tetrominoes);
}
9)
10)
11)
// try to add a tetromino to the grid, if it can fit without overlap
public boolean add(char shape) {
boolean canBePlaced = false; // can we fit the tetromino anywhere?
int topLeft = -1;
int rotation = 0;
// ... code to check whether the new tetromino fits and doesn’t overlap ...
// ... updates the values of the local variables accordingly ...
if (canBePlaced) {
tetrominoLocations.put(topLeft, new Tetromino(shape, rotation));
}
return canBePlaced;
}
12)
13)
14)
16)
// ... other operations ...
}
You may detach this page from your quiz, but you must write your name above and turn in all pages.
Programming Homework Help
15)
0 degrees 90 degrees 180 degrees 270 degrees
I
O
T
J
L
S
Z
Programming Homework Help

More Related Content

PPTX
Computer Science Assignment Help
PPTX
C Assignment Help
PPTX
Programming Homework Help
PPTX
Computer Network Assignment Help
PPTX
Electrical Engineering Exam Help
PPTX
Computational Assignment Help
Computer Science Assignment Help
C Assignment Help
Programming Homework Help
Computer Network Assignment Help
Electrical Engineering Exam Help
Computational Assignment Help

What's hot (20)

DOC
Captitude 2doc-100627004318-phpapp01
DOC
C aptitude.2doc
PPTX
Algorithm Assignment Help
PPTX
Computer Science Programming Assignment Help
PPTX
Algorithm Homework Help
PDF
100 c interview questions answers
PDF
C aptitude scribd
DOCX
C interview question answer 2
PDF
C Programming Interview Questions
PDF
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
PPT
Computer Programming- Lecture 5
PDF
46630497 fun-pointer-1
PPTX
Programming Assignment Help
ODP
Scala as a Declarative Language
PPTX
Dag representation of basic blocks
Captitude 2doc-100627004318-phpapp01
C aptitude.2doc
Algorithm Assignment Help
Computer Science Programming Assignment Help
Algorithm Homework Help
100 c interview questions answers
C aptitude scribd
C interview question answer 2
C Programming Interview Questions
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Computer Programming- Lecture 5
46630497 fun-pointer-1
Programming Assignment Help
Scala as a Declarative Language
Dag representation of basic blocks
Ad

Similar to Software Construction Assignment Help (20)

PPS
T02 a firstcprogram
PPS
T02 a firstcprogram
PDF
Core c sharp and .net quick reference
PDF
Core csharp and net quick reference
PDF
Preprocessor Programming
PPTX
Intermediate code generation1
PDF
Unit 2
PPTX
C++ Programming Homework Help
PPTX
Lecture 15_Strings and Dynamic Memory Allocation.pptx
PPT
Data type2 c
PPT
Data type in c
PDF
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
PPTX
Arrays
PPTX
Best C++ Programming Homework Help
DOCX
Write a Matlab code (a computerized program) for calculating plane st.docx
PDF
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
PDF
C Programming
DOCX
C cheat sheet for varsity (extreme edition)
T02 a firstcprogram
T02 a firstcprogram
Core c sharp and .net quick reference
Core csharp and net quick reference
Preprocessor Programming
Intermediate code generation1
Unit 2
C++ Programming Homework Help
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Data type2 c
Data type in c
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
Arrays
Best C++ Programming Homework Help
Write a Matlab code (a computerized program) for calculating plane st.docx
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
C Programming
C cheat sheet for varsity (extreme edition)
Ad

More from Programming Homework Help (20)

PPTX
Data Structures and Algorithm: Sample Problems with Solution
PPTX
Seasonal Decomposition of Time Series Data
PPTX
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
PPTX
Exploring Control Flow: Harnessing While Loops in Python
PPTX
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
PPTX
C Assignment Help
PPTX
Python Question - Python Assignment Help
PPTX
Best Algorithms Assignment Help
PPTX
Design and Analysis of Algorithms Assignment Help
PPTX
Algorithm Homework Help
PPTX
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
PPTX
Algorithm Homework Help
PPTX
Algorithms Design Assignment Help
PPTX
Algorithms Design Homework Help
PPTX
Algorithm Assignment Help
PPTX
Algorithm Homework Help
PPTX
C Homework Help
PPTX
C Homework Help
PPTX
Algorithm Assignment Help
PPTX
Computer Science Assignment Help
Data Structures and Algorithm: Sample Problems with Solution
Seasonal Decomposition of Time Series Data
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Exploring Control Flow: Harnessing While Loops in Python
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
C Assignment Help
Python Question - Python Assignment Help
Best Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
Algorithm Homework Help
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
Algorithm Homework Help
Algorithms Design Assignment Help
Algorithms Design Homework Help
Algorithm Assignment Help
Algorithm Homework Help
C Homework Help
C Homework Help
Algorithm Assignment Help
Computer Science Assignment Help

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Basic Mud Logging Guide for educational purpose
PPTX
master seminar digital applications in india
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Insiders guide to clinical Medicine.pdf
Computing-Curriculum for Schools in Ghana
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
O5-L3 Freight Transport Ops (International) V1.pdf
Microbial disease of the cardiovascular and lymphatic systems
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
Basic Mud Logging Guide for educational purpose
master seminar digital applications in india
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Insiders guide to clinical Medicine.pdf

Software Construction Assignment Help

  • 1. For any help regarding Software Construction Assignment Help Visit :- https://www.programminghomeworkhelp.com/ , Email :- support@programminghomeworkhelp.com or call us at :- +1 678 648 4277 Programming Homework Help
  • 2. (a)Which of thefollowing mustbe trueof anunderdeterminedfunction specification?(choose all that apply) A. An underdeterminedspecmeanstheimplementationisunwritten. B. An underdeterminedspecmeanstheimplementationisnondeterministic. C. An underdeterminedspecallows multiple valid outputsfor some input. D.An underdeterminedspecallows multiple valid inputsthatgive some output. (b) After thefollowing code is executed, whatis thevalue of arrayarr? (choose one answer) final String[] arr = new String[2]; String s = "6.005"; arr[0] = s; s = "is"; arr[1] = s; String t = arr[0]; t = "fun"; A. [ "is", "is" ] B. [ "6.005", "is" ] C. [ "fun", "is" ] D. none of the above (c) The line of Javacode String t = arr[0]; involves... (choose all that apply) A. assignment B. equivalence relation C. mutation D.static typing Programming Homework Help
  • 3. (d)Alyssa P.Hackeris designing animmutabletype torepresentusersinhercomputersystem. The User’s login nameis stored as: private final String kerberos; She definestwo User objects asequalif theirlogin namesarethesame,ignoring case: @Override public boolean equals(Object other) { if (!(other instanceof User)) { return false; } User that = (User)other; return this.kerberos.equalsIgnoreCase(that.kerberos); } @Override public int hashCode() { /* TODO */ } Which of thefollowing implementations of hashCode() would bevalid, satisfyingtheObject contract? (choose all that apply) A.return 31; B.return this.kerberos.hashCode(); C.return this.kerberos.toLowerCase().hashCode(); D.return this.kerberos.toUpperCase().hashCode(); (e)If thecode inanswerchoice (A) aboveappearedinyour 6.005code review assignment,which of the following commentswould beappropriatecriticisms? (choose all that apply) A. The code isn’t DRY. B. The code usesmagic numbers. C. The code exposes User’s representation. D.The code is unnecessary,we don’t needtooverridehashCode if we only returna constant. Programming Homework Help
  • 4. Problem 2 (Specifications) A tetromino is a shape made out of four adjacent squares. These shapes are most famous from the game Tetris where the player must rotate and translate falling tetrominoes in order to fit them together. There are sevenpossible tetrominoesthatlie onthe2D plane,andeachis identifiedby aletter it lookslike: I O T J L S Z Define atetromino shape letter asoneof thesevenletters IO T JL S Z, eitherupper-orlowercase. Tetrominoesmayberotatedby 0,90,180, or270 degrees. A diagram of all seven tetrominoes in all four orientations is on the last page of this quiz. Let’s defineanabstractdatatype torepresenttetrominoes: public class Tetromino { // determine if a character is a valid tetromino shape letter public static boolean isValidShape(char shape) { ... } // make a new tetromino public Tetromino(char shapeLetter, int rotationDegrees) { ... } // rotate this tetromino public void rotateClockwise() { ... } // get the shape of this tetromino public char shape() { ... } } (a) Fill inthistable with informationabouttheoperationsof Tetromino. The answersfor isValidShape arealready given. Programming Homework Help
  • 5. operation type signature classify thetypeof ADT operation Java implementation strategy isValidShape char→ boolean not applicable static method Tetromino rotateClockwise shape Programming Homework Help
  • 6. (b) Consider thesedifferent specificationsfor theisValidShapefunction: public static boolean isValidShape(char shape) /** * @param shape any character * @return true iff shape is a lowercase tetromino shape letter */ /** * @param shape an English alphabetic character * @return true iff shape is a lowercase tetromino shape letter */ /** * @param shape a lowercase tetromino shape letter * @return true */ SpecA SpecB SpecC Comparethesespecifications.Foreachpairbelow, circle one correct option andwrite write a brief explanation tocompletethesentence. A vs. B: equivalent to weakerthan strongerthan incomparable to SpecA is specB because B vs. C: equivalent to weakerthan strongerthan incomparable to SpecB is specC because Programming Homework Help
  • 7. Problem 3 (AFs & RIs) Hereis animplementationof theTetrominoADT. /** A rotatable tetromino. */ public class Tetromino { // ... static method isValidShape ... private final char shape; private int rotation; // Abstraction function // TODO // Representation invariant // TODO // Safety from rep exposure // TODO /** * Make a new Tetromino with the given shape and rotation. * @param shapeLetter uppercase tetromino shape letter * @param rotationDegrees clockwise rotation in degrees, * must be 0, 90, 180, or 270 Programming Homework Help
  • 8. */ public Tetromino(char shapeLetter, int rotationDegrees) { this.shape = shapeLetter; this.rotation = rotationDegrees / 90; } /** * TODO */ public void rotateClockwise() { rotation = (rotation + 1) % 4; } /** * @return shape of this tetromino: ’I’ ’O’ ’T’ ’J’ ’L’ ’S’ or ’Z’ */ public char shape() { return shape; } @Override public String toString() { return shape + "-shape@" + rotation * 90 + "deg"; } } Programming Homework Help
  • 9. (a) For each of the statements below, say whether it should be included in the internal documentation of Tetromino by writing: AF if the statement belongs in the abstraction function RI ... the rep invariant EXP ... the argument that type has no rep exposure NONE if it should not be included in any of those You should include in the AF, RI, or EXP all good statements that are compatible with the code and specs on the previous page. Do not include statements that are not compatible with the code and specs. shape is private and an immutable value rotation is private and an immutable value this Tetromino is never returned to clients shape is an uppercase tetromino shape letter shapeLetter is an uppercase tetromino shape letter the tetromino has the shape given by shape rotation = 0 the tetromino is rotated clockwise by rotation Programming Homework Help
  • 10. the tetromino is rotated clockwise rotation times 90 degrees 0 <= rotation < 4 0 <= rotation < 360 rotation is one of { 0, 90, 180, 270 } Consider thesedifferent specificationsfor therotateClockwisemethod: public void rotateClockwise() Programming Homework Help
  • 11. Foreachpossiblespecificationbelow, write a one-sentence code review comment that identifies themost serious problem with the spec. (b) /** * Update this tetromino’s rotation number to add 1, mod 4. */ Comment: (c) /** * @return this tetromino rotated by 90 degrees clockwise */ Comment: (d) /** * Rotate this tetromino (does not otherwise modify the tetromino). */ Comment: Programming Homework Help
  • 12. Problem 4 Let’s consider the problem of packing tetrominoes into a rectangle by rotating and translating them in the 2D plane. For example, here are tetrominoes I, L, & Z packed into a 5 × 4 rectangle, and a 7 × 2 rectangle: For those three tetrominoes, the minimum area they can be packed into is 7 × 2 = 14 squares. (a) /** * @param shapes string of tetromino shape letters * @return a 2-element list representing a minimum-area rectangle into which * the tetrominoes given by shapes can be packed * (for example, pack("ILZ") might return the list [ 2, 7 ]) */ public static List pack(String shapes) { ... } Start writing a black box testing strategy for pack(..) by giving one good partitioning for input shapes: For each of the test cases below, in the first box write YES or NO in the first box to say whether the test valid or not. If the test is not valid, write a one-sentence reason why not. We’ll use Python’s syntax to represent lists for brevity Programming Homework Help
  • 13. Problem 5 (Rep Exposure) . Let’s define a mutable abstract data type TetrominoGrid to represent tetrominoes arranged on a fixed-size grid, where every tetromino fits on the grid and none of the tetrominoes overlap. For example: Programming Homework Help
  • 14. On the next page is an implementation of TetrominoGrid. In its rep, TetrominoGrid stores the location of each tetromino using a map from integers to tetrominoes. The integer keys are square numbers: Each square in the grid is numbered starting from 0 in the upper-left corner. On a grid of width width, square at row row and column col is numbered row × width + col. For example, here’s how our type would represent the example above: width = 5, height = 4 tetrominoLocations = { 0: (Tetromino: I-shape rotated 0 degrees), 3: (Tetromino: L-shape rotated 0 degrees), 6: (Tetromino: Z-shape rotated 90 degrees) } The TetrominoGrid ADT is implemented using the same mutable Tetromino ADT from previous questions. (a) Identify all instances of rep exposure in TetrominoGrid on the next page. For each one, write: 1. the line number most directly responsible for the problem, 2. at most one-sentence description of the rep exposure, and 3. at most one-sentence description of how to fix the problem, or a single corrected line of code. There may be more boxes than you need. Programming Homework Help
  • 15. Line #: Explanation: Line #: Explanation: Line #: Explanation: Line #: Explanation: Line #: Explanation: You may detach this page from your quiz, but you must write your name above and turn in all pages. /** * Mutable type representing a fixed-size grid with a valid arrangement of * tetrominoes: every tetromino fits on the grid without overlapping. */ public class TetrominoGrid { 1) private final int width; 2) private final int height; 3) public final Map<Integer, Tetromino> tetrominoLocations; Programming Homework Help
  • 16. // create a new grid and try to add some tetrominoes public TetrominoGrid(int width, int height, List<Tetromino> initial) { this.width = width; this.height = height; this.tetrominoLocations = new HashMap<>(); for (Tetromino tetromino : initial) { this.add(tetromino.shape()); } } 4) 5) 6) 7) // get the tetromino whose upper-left corner is the given square public Tetromino getTetrimino(int row, int col) { return tetrominoLocations.get(row * width + col); } 8) // return a list of all tetriminos currenty on the grid public List<Tetromino> getTetriminosOnBoard() { List<Tetromino> tetrominoes = new ArrayList<>(); for (Tetromino tetromino : tetrominoLocations.values()) { tetrominoes.add(tetromino); } return Collections.unmodifiableList(tetrominoes); } 9) 10) 11) // try to add a tetromino to the grid, if it can fit without overlap public boolean add(char shape) { boolean canBePlaced = false; // can we fit the tetromino anywhere? int topLeft = -1; } 12) 13) 14) 15) Programming Homework Help
  • 17. int rotation = 0; // ... code to check whether the new tetromino fits and doesn’t overlap ... // ... updates the values of the local variables accordingly ... if (canBePlaced) { tetrominoLocations.put(topLeft, new Tetromino(shape, rotation)); } return canBePlaced; 16) // ... other operations ... } You may detach this page from your quiz, but you must write your name above and turn in all pages. Programming Homework Help
  • 19. Problem 1 (Multiple Choice) (a)Which of the following must be true of an underdetermined function specification? (choose all that apply) A.An underdetermined spec means the implementation is unwritten. B. An underdetermined spec means the implementation is nondeterministic. C. An underdetermined spec allows multiple valid outputs for some input. D.An underdetermined spec allows multiple valid inputs that give some output. Solution. C. None of the other options must be true. □ (b) After the following code is executed, what is the value of array arr? (choose one answer) final String[] arr = new String[2]; String s = "6.005"; arr[0] = s; s = "is"; arr[1] = s; String t = arr[0]; t = "fun"; A. [ "is", "is" ] B. [ "6.005", "is" ] C. [ "fun", "is" ] D. none of the above Solution. B. The reassignment of sto "is"or tto "fun"do not affect arr[0]. □ Programming Homework Help
  • 20. (c) The line of Java code String t = arr[0]; involves... (choose all that apply) A.assignment B. equivalence relation C.mutation D.static typing Solution. A, D. This line assigns to t, which has static type String. □ (d) Alyssa P. Hacker is designing an immutable type to represent users in her computer system. The User’s login name is stored as: private final String kerberos; She defines two Userobjects as equal if their login names are the same, ignoring case: @Override public boolean equals(Object other) { if (!(other instanceof User)) { return false; } User that = (User)other; return this.kerberos.equalsIgnoreCase(that.kerberos); } Programming Homework Help
  • 21. @Override public int hashCode() { /* TODO */ } Which of the following implementations of hashCode() would be valid, satisfying the Object contract? (choose all that apply) A.return 31; B.return this.kerberos.hashCode(); C.return this.kerberos.toLowerCase().hashCode(); D.return this.kerberos.toUpperCase().hashCode(); Solution. A, C, D. A is correct, although not necessarily a good hash function. C and D are correct because Strings that are equal ignoring case will have the same value for both toLowerCase()and toUpperCase(). B is incorrect because two Users with with login names that differ only in case will have different hash codes even though the Userobjects are equal. □ (e)If the code in answer choice (A) above appeared in your 6.005 code review assignment, which of the following comments would be appropriate criticisms? (choose all that apply) A.The code isn’t DRY. B.The code uses magic numbers. C.The code exposes User’s representation. D.The code is unnecessary, we don’t need to override hashCodeif we only return a constant. Solution. B. 31 is a magic number. □ Problem 2 (Specifications) A tetromino is a shape made out of four adjacent squares. These shapes are most famous from the game Tetris where the player must rotate and translate falling tetrominoes in order to fit them together. There are seven possible tetrominoes that lie on the 2D plane, and each is identified by a letter it looks like: Programming Homework Help
  • 22. I O T J L S Z Define a tetromino shape letter as one of the seven letters I O T J L S Z, either upper- or lowercase. Tetrominoes may be rotated by 0, 90, 180, or 270 degrees. A diagram of all seven tetrominoes in all four orientations is on the last page of this quiz. Let’s define an abstract data type to represent tetrominoes: public class Tetromino { // determine if a character is a valid tetromino shape letter public static boolean isValidShape(char shape) { ... } // make a new tetromino public Tetromino(char shapeLetter, int rotationDegrees) { ... } // rotate this tetromino public void rotateClockwise() { ... } // get the shape of this tetromino public char shape() { ... } } (a) Fill in this table with information about the operations of Tetromino. The answers for isValidShapeare already given. Programming Homework Help
  • 23. operation type signature classify the type of ADT operation Java implementation strategy isValidShape char→ boolean not applicable static method Tetromino char×int→Tetromino creator constructor rotateClockwise Tetromino→ void mutator instance method shape Tetromino→ char observer instance method (b) Consider these different specifications for the isValidShapefunction: public static boolean isValidShape(char shape) /** * @param shape any character * @return true iff shape is a lowercase tetromino shape letter */ /** * @param shape an English alphabetic character * @return true iff shape is a lowercase tetromino shape letter */ SpecA Spec B Programming Homework Help
  • 24. Compare these specifications. For each pair below, circle one correct option and write write a brief explanation to complete the sentence. Solution. Spec A is stronger than spec B because its precondition is weaker and its postcondition is the same. Solution. Spec B is stronger than spec C because it has a weaker precondition, and it satisfies C’s postcondition for any input that satisfies C’s precondition. Problem 3 (AFs & RIs) Here is an implementation of the Tetromino ADT. /** A rotatable tetromino. */ public class Tetromino { Programming Homework Help
  • 25. // ... static method isValidShape ... private final char shape; private int rotation; // Abstraction function // TODO // Representation invariant // TODO // Safety from rep exposure // TODO public Tetromino(char shapeLetter, int rotationDegrees) { this.shape = shapeLetter; this.rotation = rotationDegrees / 90; Programming Homework Help
  • 26. (a) For each of the statements below, say whether it should be included in the internal documentation of Tetromino by writing: AF if the statement belongs in the abstraction function RI ... the rep invariant EXP ... the argument that type has no rep exposure NONE if it should not be included in any of those You should include in the AF, RI, or EXP all good statements that are compatible with the code and specs on the previous page. Do not include statements that are not compatible with the code and specs. shape is private and an immutable value rotation is private and an immutable value this Tetromino is never returned to clients shape is an uppercase tetromino shape letter shapeLetter is an uppercase tetromino shape letter the tetromino has the shape given by shape rotation = 0 the tetromino is rotated clockwise by rotation the tetromino is rotated clockwise rotation times 90 degrees 0 <= rotation < 4 0 <= rotation < 360 rotation is one of { 0, 90, 180, 270 } Programming Homework Help
  • 27. Solution. EXP EXP NONE (doesn’t make sense) RI NONE (part of the precondition of the constructor) AF NONE NONE AF (see e.g. toString) RI (established by constructor, maintained by rotateClockwise) NONE NONE □ Consider these different specifications for the rotateClockwisemethod: public void rotateClockwise() For each possible specification below, write a one-sentence code review comment that identifies the most serious problem with the spec. (b) /** * Update this tetromino’s rotation number to add 1, mod 4. */ Comment: Solution. The specification must be abstract, it should not talk about the representation. The specification should be declarative, not operational. □ Programming Homework Help
  • 28. (c) /** * @return this tetromino rotated by 90 degrees clockwise */ Comment: Solution. The specification, which says a Tetrominois returned, does not agree with return type void. □ (d) /** * Rotate this tetromino (does not otherwise modify the tetromino). */ Comment: Programming Homework Help
  • 29. Solution. This specification is too weak, it does not specify the amount of rotation. □ Problem 4 Let’s consider the problem of packing tetrominoes into a rectangle by rotating and translating them in the 2D plane. For example, here are tetrominoes I, L, & Z packed into a 5 × 4 rectangle, and a 7 × 2 rectangle: Start writing a black box testing strategy for pack(..) by giving one good partitioning for input shapes: For each of the test cases below, in the first box write YES or NO in the first box to say whether the test valid or not. If the test is not valid, write a one-sentence reason why not. We’ll use Python’s syntax to represent lists for brevity. Programming Homework Help
  • 30. (b) shapes = "X" rectangle = [ 0, 0 ] Valid? Reason if invalid: Solution. Invalid: shape X violates the precondition (c) shapes = "I" rectangle = [ 1, 4 ] Valid? Reason if invalid: Solution. Invalid: rectangle [ 4, 1 ] is also allowed by the postcondition. d) shapes = "LO“ rectangle = [ 3, 3 ] Valid? Reason if invalid: Solution. Valid. Problem 5 Let’s define a mutable abstract data type TetrominoGrid to represent tetrominoes arranged on a fixed-size grid, where every tetromino fits on the grid and none of the tetrominoes overlap. For example: Programming Homework Help
  • 31. On the next page is an implementation of TetrominoGrid. In its rep, TetrominoGrid stores the location of each tetromino using a map from integers to tetrominoes. The integer keys are square numbers: Each square in the grid is numbered starting from 0 in the upper-left corner On a grid of width width, square at row row and column col is numbered row × width + col. For example, here’s how our type would represent the example above: The TetrominoGrid ADT is implemented using the same mutable Tetromino ADT from previous questions. (a) Identify all instances of rep exposure in TetrominoGrid on the next page. For each one, write: 1. the line number most directly responsible for the problem, 2. at most one-sentence description of the rep exposure, and 3. at most one-sentence description of how to fix the problem, or a single corrected line of code. There may be more boxes than you need. Line #: Explanation: Line #: Explanation: Line #: Explanation: Line #: Explanation: Line #: Explanation: Programming Homework Help
  • 32. Solution. Line 3: tetrominoLocations can be accessed and mutated by clients. It should be private. Line 8: returns a Tetromino that is in the rep, clients could mutate it and break the rep invariant. Should return a defensive copy. Line 11 (or 10): returns an unmodifiable list, but the Tetromino objects are still mutable parts of the rep. Should return defensive copies. public class TetrominoGrid { 1) private final int width; 2) private final int height; 3) public final Map<Integer, Tetromino> tetrominoLocations; // create a new grid and try to add some tetrominoes public TetrominoGrid(int width, int height, List<Tetromino> initial) { this.width = width; this.height = height; this.tetrominoLocations = new HashMap<>(); for (Tetromino tetromino : initial) { this.add(tetromino.shape()); } } 4) 5) 6) 7) Programming Homework Help
  • 33. // get the tetromino whose upper-left corner is the given square public Tetromino getTetrimino(int row, int col) { return tetrominoLocations.get(row * width + col); } 8) // return a list of all tetriminos currenty on the grid public List<Tetromino> getTetriminosOnBoard() { List<Tetromino> tetrominoes = new ArrayList<>(); for (Tetromino tetromino : tetrominoLocations.values()) { tetrominoes.add(tetromino); } return Collections.unmodifiableList(tetrominoes); } 9) 10) 11) // try to add a tetromino to the grid, if it can fit without overlap public boolean add(char shape) { boolean canBePlaced = false; // can we fit the tetromino anywhere? int topLeft = -1; int rotation = 0; // ... code to check whether the new tetromino fits and doesn’t overlap ... // ... updates the values of the local variables accordingly ... if (canBePlaced) { tetrominoLocations.put(topLeft, new Tetromino(shape, rotation)); } return canBePlaced; } 12) 13) 14) 16) // ... other operations ... } You may detach this page from your quiz, but you must write your name above and turn in all pages. Programming Homework Help 15)
  • 34. 0 degrees 90 degrees 180 degrees 270 degrees I O T J L S Z Programming Homework Help