2ME3 - Assignment 3
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
2ME3 - Assignment 3
Overview
There are no other files associated with this document. You are responsible for submitting one file: 1. Mystery1 .java
See below for details on what you are responsible for completing.
Your Tasks
At the end of this document is an MIS . You are responsible for implementing this specification. Mystery1 and Mystery2 are not associated with each other in any way. Think of them as two sepa- rate questions. You may import/use ArrayLists and HashMaps if you wish.
Submitting and Grading
This assignment will be submitted electronically via Avenue. Part of your assignment will be auto graded, part will be done manually. A rough breakdown is given below.
❼ Mystery1 .java: 100%
– f1: 10%
– f2: 40%
– f3: 50%
Code which does not compile will be heavily penalized. Code which has incorrect method/module names will be penalized up to 20% Good luck!
Academic Dishonesty Disclaimer
All of the work you submit must be done by you, and your work must not be submitted by someone else. Plagiarism is academic fraud and is taken very seriously. The department uses software that compares programs for evidence of similar code.
Please don’t copy. The TAs and I want you to succeed and are here to help. Here are a couple of general guidelines to help you avoid plagiarism:
Never look at another assignment solution, whether it is on paper or on the computer screen. Never show another student your assignment solution. This applies to all drafts of a solution and to incomplete solutions. If you find code on the web that solves part or all of an assignment, do not use or submit any part of it! A large percentage of the academic offenses in involve students who have never met, and who just happened to find the same solution online. If you find a solution, someone else will too.
Mystery1 Module Interface
Uses
None
Syntax
Exported Types
Mystery1 = ?
Exported Access Routine
Routine Name |
In |
Out |
Exceptions |
new Mystery1 |
|
Mystery1 |
None |
f1 |
String, String |
|
None |
f2 |
String |
N |
None |
f3 |
String, String |
B |
None |
Semantic
Local Types
X = tuple(s1 :String, s2 :String)
State Variables
S : X{}
Assumptions
❼ All inputs are of the proper type.
❼ The notation X(s1 , s2 ) is shorthand for saying (s1 , s2 ) is a tuple of type X.
Access Routine Semantics
Mystery1():
❼ transition: S = {}
❼ output: out := this
f1(s1 , s2 ):
❼ transition:
s1 s2 ÷ S := S u {X(s1 , s2 )}
s1 = s2 ÷ S := S
f2(s):
❼ output: out := +(x : X|x e S A x.s2 = s : 1)
f3(s1 ,s2 ):
❼ output: out :=
3(L :String[ ]| L[0] = s1 A L[|L| - 1] = s2 : P (L) A X(L[|L| - 1], L[0]) e S)
Local Functions
P (L) :String[ ]→ B
P (L) = A(i : N|0 < i < |L| : X(L[i - 1], L[i]) e S)
2022-12-06