联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> javajava

日期:2020-11-13 11:40

School of Computing & Information Technology

CSCI251/CSCI851/HCSC851

Advanced Programming

Spring 2020

Assignment 3 (Worth 8%)

Due 11:55pm Saturday 14nd November 2020. (End of Week Thirteen)

This assignment involves implementing a Collection class template and functionality to support

comparisons between entites stored within the container based on the features of those entites. We will

specifically be looking at collections of Vehicles and of Animals.

General notes

These are some general rules about what you should and shouldn’t do.

1. Your assignment should be sensibly organised with the same kind of expectations in this area as the

previous assignments, although you can directly include the cpp this time since it’s templated.

2. If your code fails to compile on capa with the instruction below you will likely receive zero.

$ g++ A3.cpp libGen.a -o EIC

3. You should not modify generate.h, and you shouldn’t submit it either.

4. Other than the initial command line input, the program should run without user input.

5. You should use classes.

6. You should use templating.

7. You shouldn’t use inheritance.

8. Failure to comply with any of the three points above will result in significant penalties.

1

The entity classes

The entity classes should not be related by inheritance.

The two entity classes are similar, in that each has a sequence of features used to describe the instances

of that class and used to determine the difference between entities of the same type. The primary difference

between the entity classes is the way in which the features are compared.

1. The first entity class is Vehicle. Each feature in this is a single integer value in the range 0 to p?1,

where p is a positive integer, the modulus. The difference between Vehicle objects is the sum of

the differences modulo p between the corresponding features. The sum itself is not modulo p.

2. The second entity class is Animal. Each feature in this is a single uppercase letter from the English

alphabet. The difference between Animal objects is a count of the number of corresponding features

with different values.

Each of the entity classes will have a base value, with the base value being 0 for Vehicle and ’A’ for

Animal.

Each of the entity classes needs the following methods.

1. The method calcGravity should determine the number of elements in the feature sequence that are

not–equal to the base symbol. For example, a Vehicle feature list (6 2 1 2 0 5 0) has a gravity

of 5, and an Animal feature list (C A T) has a gravity of 2.

2. The method calcDifference should take another entity of the same type and determine the sum

of the element by element difference according to the difference described earlier.

For example, the difference between Vehicle feature sequences (1 1 2 3 0 1) and (0 0 2 0 0 3)

for with p = 7 would be determined as

1 1 2 3 0 1

- 0 0 2 0 0 3

--------------

1+1+0+3+0+5 = 10

3. The method Display should output the features in each entity, each separated by a space, with a

final gap and the gravity of the entity displayed. For example, for Vehicle

6 2 1 2 0 5 0 Gravity: 5

or for Animal

C A T Gravity: 2

2

The Collection container

You need to write a class template Collection to store multiple instances of another class, referred to

generally as entities. For the purposes of the assignment the only objects that are to be stored will be

either Vehicles or Animals, but the template should be written to work for any other type consistent with

the interface, which would mean the functions described above.

The following methods should be provided.

1. The method minimumGravity should determine the minimum Gravity value across all non–base

feature sequences.

2. The method calcDifference should determine the difference between every pair of entities in the

container, and store these values.

3. The method minimumDifference should determine the minimum Difference between two entites

in the container, as determined across all distinct pairs of entities.

4. The method Display should display all the entities contained in the collection, using the Display

method for the entities themselves, and display the minimum gravity and minimum difference for

this code. The table of differences between entities should be displayed also.

This container should contain a base feature sequence, with the features being all equal to the base

value for that type. So for Vehicle the base feature sequence will be (0 0 0 0 0 ...), while for Animal

is will be (A A A ...).

Entities in Containers : The main() function

Once your program is compiled into the executable EIC it must run as follows:

./EIC 0 seed length size modulus

./EIC 1 seed length size

where the parameters have the following meanings:

? First argument : The entity to be used: (0 for Vehicle, 1 for Animal).

? seed : A positive integer. Random seed for use in the feature generator functions.

? length : A positive integer. The number of features in each entity.

? size : A positive integer. The number of entities in the collection.

? modulus : A positive integer, only relevant for the Vehicle code.

You generate values to populate your entities by making calls to the functions provided in generate.h

and libGen.a, using seed and modulus as arguments as needed.

After populating the collection, you should calculate the minimum gravity, minimum difference, and

difference values for the container. The code should be displayed using the container method Display().

3

Some test data

Here goes a couple of test data cases. These are the actual feature values, including the base feature

sequence. I’ll illustrate the calculation of these in the Week 11 lecture/tutorial. Note that the base feature

sequence is included in the count of the number of entities in the container.

./EIC 0 10 5 4 10

0 0 0 0 0 Gravity: 0

7 6 2 8 8 Gravity: 5

8 9 1 9 7 Gravity: 5

4 7 6 6 7 Gravity: 5

Minimum gravity: 5

Difference table:

0 19 16 20

31 0 27 21

34 23 0 14

30 29 26 0

Minimum difference: 14

./EIC 1 14 3 4

A A A Gravity: 0

H E N Gravity: 3

V E X Gravity: 3

B U U Gravity: 3

Minimum gravity: 3

Difference table:

0 3 3 3

3 0 2 3

3 2 0 3

3 3 3 0

Minimum diffference: 2

Notes on submission

Submission is via Moodle. Your code must compile on capa with the instructions you provide. If it doesn’t

you will likely be given zero for this assignment.

Please submit your source, so .cpp and .h files, in a zip file A3.zip. There shouldn’t be

any directory structure within the zip file. Please don’t submit generate.h or libGen.a.

1. The deadline is 11:55pm Saturday 14th November 2020.

2. Late submissions will be marked with a 25% deduction for each day, including days over the weekend.

3. Submissions more than three days late will not be marked, unless an extension has been granted.

4. If you need an extension apply through SOLS, if possible before the assignment deadline.

5. Plagiarism is treated seriously. Students involved will likely receive zero.


c Luke McAven, SCIT-EIS-UOW, 2020.

4


版权所有:留学生程序网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。