程序代写案例-CSSE2002/7023
时间:2021-11-01
CSSE2002/7023 Semester 1 2020 Final Exam Marking Criteria

Question 1
N/A – used for starting assumptions during exam

Question 2
false
false
false
true

Question 3
[1, 2, 3, 3, 4, 5]

Question 4
Coder?

Question 5
1234
5678

Question 6
The method z would throw an exception.

Question 7
5

Question 8
A r1 = (A)c;

B r2 = (B)d;

D r6 = (D)d;















Question 9
Subclass B uses protected data member d from superclass and modifies protected
datamember i from superclass. It also overrides doOther to change its behaviour, and allows
a downcall.

A, C and D are as tightly coupled as possible.

12 Marks
• 3 marks for identifying overall tight coupling
• 3 marks for a very general explanation

• 3 marks for the links between methods & how this increases coupling
o Need example(s) for more than 1 mark of this
o e.g. cycle between C & A
o e.g. “forwarding of behaviour” A.doSomething just calling c.doC()
• 1 marks for dependency on instances that need init out of constructor (C & D)
• 1 marks for identifying there is inheritance coupling
o Should mention use of protected method
▪ d.doD
• 1 marks for all classes use all others that are possible
o i.e. A uses B,C,D, B uses A,C,D, etc...

• Deduction for major contradictions of previous good answers
o Half of the previously given mark
o Full mark deduction for single sentence contradiction of premise (high/low)


Question 10
0
C
D
















Question 11
6 marks for explanation of MVC.
• 2 Marks for Explain idea of model representing state/data
• 2 Marks for Explain idea of UI providing user interaction
o Separation of View & Controller - can be implicit
• 2 Marks for Explain how it all works together
o How elements interact/communicate.
o Changes to the interface reflected in the model and vice versa

4 marks for describing the benefit of the MVC approach.
• Only need to describe one benefit (i.e. “purpose” from question)
• But need to clearly explain the reason for the approach (the why), not just say that it
provides separation between M, V & C
o 2 marks for identifying at least one purpose of MVC
o 2 marks for reasonable explanation of purpose or value of providing the
separation


Question 12
4 marks each question
• 1 mark for identifying if it meets LSP or not
• 2 marks for a correct general explanation
o Has the pre/postcondition been weakened/strengthened
• 1 mark for detail
o Wider range of inputs; > changed to >=; etc.

1. B wrt A
• Satisfies LSP
• Precondition weaker (less restrictive), postcondition stronger (more restrictive).
• variance <= 1 weaker than variance < 1,
• Math.abs(values[i] - targets[i]) < variance stronger than Math.abs(values[i] -
targets[i]) <= variance

2. C wrt A
• Violates LSP
• Precondition stronger (more restrictive), postcondition unchanged
• variance > 0 stronger than variance >= 0

3. D wrt A
• Satisfies LSP
• Precondition weaker (less restrictive), postcondition unchanged
• values.size() <= targets.size() weaker than values.size() == targets.size()




Question 13
Black Box Tests: 11 marks
• Both lists are empty (2 marks), or size of 1 (1 mark)
• Values & targets same size (1 mark)
• Values.size() < targets.size()(1 mark)
• Variance is 0 (2 marks)
• Variance is valid value (1 mark)
• Output is empty (2 marks)
• Output has results (2 marks)
o A value in “targets” is larger than corresponding value in “values” - should
justify
o A value in “values” is larger than corresponding value in “targets”
• -½ mark for each incorrect justification (only for inputs that are contributing to
marks)

White Box Tests: 7 marks (1 mark each)



















Question 14
JavaDoc: 7 marks
• 1 mark for Description
• 1 mark for params
• 1 mark for return
• 2 marks for pre condition
o 1 for string can’t be null (or implicitly via str.length())
o 1 for bounds check on strLengthToTest (general)
• 2 marks for post condition
o 2 marks for restating return clearly and unambiguously

Code: 9 marks
Base Case:
• 1 mark for base case exists
• 1 mark for condition
• 1 mark for correct return
Recursive Case:
• 2 mark for recursive case exists
o 1 for consonant case
o 1 for vowel case
• 1 mark for reducing input (not infinite recursion)
• 1 mark for returning result (i.e. deduct if “return” missing)
• 2 marks for adding or not adding in recursive return:
o 1 mark for adding to result (i.e. return 1 + …) in the consonant case
o 1 mark for not adding to result in return in the vowel case


static int totalConsonantsRecursive(String str, int strLengthToTest) {
if (strLengthToTest == 1) {
if(isConsonant(str.charAt(0)))
return 1;
else
return 0;
}
if(isConsonant(str.charAt(strLengthToTest - 1)))
return totalConsonantsRecursive(str, strLengthToTest - 1) + 1;
else
return totalConsonantsRecursive(str, strLengthToTest - 1);
}










Question 15
8 marks for implementation of generic Kennel.
• 2 for generic type parameter
o 1 for just
o 2 for correct restriction on Pet
• 1 for generic list member variable
• 1 for instantiating the list (even if list variable is not generic)
• 2 for has addPet method or similar
o 1 for Exists
o 1 for Has generic param
• 2 for has retrievePet
o 1 for Exists incl. Must have/use int param
o 1 mark for generic return value

6 marks for Non-Generic Explanation
• 2 marks for explanation of Kennel having a collection of Pets
o i.e. List
• 2 marks for explanation that a generic Kennel has the additional restriction of
collections of only specific subtypes of Pets.
o i.e. Kennel, Kennel
• 2 marks for rationale of the restriction.
▪ Ensure that the class/method is operating on instances with
appropriate methods/data.
o Saves manual checking of types in runtime logic
o Benefits of animal-specific kennels (i.e. real world kennels)






















package generics;

import java.util.ArrayList;
import java.util.List;

class Pet { }
class Cat extends Pet { }
class Dog extends Pet { }

public class Kennel {
private List pets;

public Kennel() {
pets = new ArrayList<>();
}

public void addPet(T pet) {
pets.add(pet);
}

public T getPet(int petLocation) {
return pets.get(petLocation);
}

public static void main(String... args) {
Kennel cattery = new Kennel<>();
Kennel dogKennel = new Kennel<>();
cattery.addPet(new Cat());
dogKennel.addPet(new Dog());
}
}

学霸联盟





































































































































































































































o 2 for correct restriction on Pet
• 1 for generic list member variable
• 1 for instantiating the list (even if list variable is not generic)
• 2 for has addPet method or similar
o 1 for Exists
o 1 for Has generic param
• 2 for has retrievePet
o 1 for Exists incl. Must have/use int param
o 1 mark for generic return value

6 marks for Non-Generic Explanation
• 2 marks for explanation of Kennel having a collection of Pets
o i.e. List
• 2 marks for explanation that a generic Kennel has the additional restriction of
collections of only specific subtypes of Pets.
o i.e. Kennel, Kennel
• 2 marks for rationale of the restriction.
▪ Ensure that the class/method is operating on instances with
appropriate methods/data.
o Saves manual checking of types in runtime logic
o Benefits of animal-specific kennels (i.e. real world kennels)






















package generics;

import java.util.ArrayList;
import java.util.List;

class Pet { }
class Cat extends Pet { }
class Dog extends Pet { }

public class Kennel {
private List pets;

public Kennel() {
pets = new ArrayList<>();
}

public void addPet(T pet) {
pets.add(pet);
}

public T getPet(int petLocation) {
return pets.get(petLocation);
}

public static void main(String... args) {
Kennel cattery = new Kennel<>();
Kennel dogKennel = new Kennel<>();
cattery.addPet(new Cat());
dogKennel.addPet(new Dog());
}
}

学霸联盟


essay、essay代写