Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP1202. Programming I

(2023-24)

Coursework: EcsSim (Version 3.0)

Submission deadline:    4pm, 15 December 2023

Feedback:      26 January 2024

Weighting:    45%

Coursework is the continuously assessed part of the examination and is a required part of the degree assessment. Assessed work must be submitted as specified below.  You are reminded to read all of the following instructions carefully.

Please note: Any alterations to the coursework will be submitted to the course wiki: https: //secure.ecs.soton.ac.uk/student/wiki/w/COMP1202/Coursework . If issues are found with the specification it will be revised if necessary.  The coursework specification will contain the change log.  If questions arise as to how certain aspects might be implemented then suggestions of approaches may be made but these will be suggestions only and not defined parts of the specification.

Late submissions will be penalised at 10% per working day.  No work can be accepted after feedback has been given. You should expect to spend up to 45 hours on this assignment.

This coursework is to be completed individually.  Please note the University regula- tions regarding academic integrity (https://www.southampton.ac.uk/quality/assessment/ academic_integrity.page).

Release Notes

Date

Version

Description

27/10/2023

1.0

Initial Specification Document

30/10/2023

1.1

Minor typos fixed

.  Fix        typo        {getMaintenanceCost        (was

getMaintanenceCost

. upgrade building gains 50 reputation points for the University

.  Clarify when to throw exceptions when upgrade building.

31/10/2023

2.0

Part 5:  Change students yearly contributions from 1 to 10  ECScoins per student.   Additional  clarications  on building facilities and hiring staff.

6/11/2023

2.1

Fix the academic year (2023-24).

Part 4: Fixed typos in the diagram (Figure 4).

20/11/2023

3.0

Fixed typos (getNumberOfStudents) in figures

Part 5: Deduct reputation for unintructed students.

Coursework Aims

This coursework allows you to demonstrate that you:

.  Understand how to construct simple classes and implement methods.

.  Are able to take simple pseudo-code descriptions and construct working Java code from them.

.  Can write aworking program to perform a complex task.

.  Have an understanding of object-oriented programming.

.  Can correctly use polymorphism, exceptions and I/O.

.  Can write code that is understandable and conrms good coding practice.

Contacts

General programming queries should be made to your demonstrator in the timetabled labs.

Queries about the coursework specification should be made to Son Hoang ([email protected]).

Any issues that may affect your ability to complete the coursework should be made known to Son Hoang ([email protected]), ideally before the submission deadline.

Specification

The aim of this coursework is to construct a virtual representation of a university.  This univer- sity will consist of a number of facilities and staff contributing to the growth of the university. Based on this concept of a university, we will create a simple simulation called “EcsSim”.

You are not required to have any knowledge of building/managing a university or experience in similar city/town-building simulation games in order to complete this coursework.

The ECS Sim may bear some similarities to a real university but is very simplified and in some cases likely to be quite different to how a university might work.   Your  task  is  to implement the specification as written.

In some cases, specific names are defined or specific properties are given for classes.  This is mainly to ensure that we can easily read your code, and find the parts that are most relevant to the marking scheme.  You will not gain marks for deviating from the specification in order to increase the realism of the simulation.  In fact,  it may  cost you marks  and make it harder to  assess  what  you have  written.   In some cases, we wish to know that you can use specific Java constructs, so if it specifies an ArrayList then we want to see you use an ArrayList. There might be other ways of implementing the same feature but we are trying to assess your ability to use specific constructs. Where the specification is less explicit in the way something is implemented (for example, by omitting what data types to use) you are free to make your own choices but will be assessed on how sensible those choices are.  Comments in your code should explain the choices you have made.

How the EcsSim Works

For this coursework, you are expected to follow the specification of a university as set out below. This may not correspond exactly to a university in reality but we have chosen particular aspects for you to model that help you to demonstrate your Java programming skill.

There are several objects and people that contribute to the university.  For our purposes, these include:

.  Halls  facilities providing accommodation for students.

.  Labs – facilities for laboratory sessions, required for students to train their practical skills.

.  Theatres – facilities for lectures, required for students to learn theoretical knowledge. .  Sta: Staff instruct the students in laboratory sessions and lectures.

The main purpose of EcsSim is to build facilities and to hire staff using “EcsCoins”  (the simulation currency) to create a successful university.  The university will gain its reputation and EcsCoins by teaching the students.

The next sections will take you through the construction of the various objects and people in your university.  You are requested to follow this sequence of development as it will allow you to slowly add more functionality and complexity to your university.

Part 1 - Modelling the Facilities

The Facility Class

Before modelling the various types of buildings, we first model the Facility class, which will be the basis for any facility.

.  Create a package called facilities.

.  The property for the Facility class (in the facilities pack- age) that you will need to define is:

 name  this is the name of the facility.

.  Define the property as you think appropriate, and create a con- structor that initialises the property with the following signa- ture

Facility(String name)

.  Define the accessor methods

 getName()  return the name of the facility.

The Building Interface

The Building interface is common for all types of buildings.  Each building can be at a certain level (starting from Level 1).  Further- more, each type of buildings, e.g., Hall, Lab or Theatre, will have a maximum level that cannot be exceeded (see Table 1).  Follow the steps below to create this interface.

.  Create a (sub-)package called buildings inside the facilities package (i.e., facilities.buildings).

.  The  abstract  methods  of the  Building  interface  (inside  the facilities.buildings package) areas follows:

–  int  getLevel() – return the current level of the building.

 void  increaseLevel() – increase the level of the build- ing. The assumption is that this method can only be called when the building can be upgraded (i.e., it is not yet at its maximum level).

–  int  getUpgradeCost() – return the cost for upgrading the building to the next level.  This cost depends on the type of the building and the current building level.  Return -1 if the building cannot be upgraded (i.e., it is already at its maximum level).

  int  getCapacity():  return the current capacity of the building.  This depends on the type of the building and the current building level.

 

Source: freepik.com

 

Source: freepik.com

The Hall, Lab, and Theatre Classes

To model the various types of building you will need for your university you will need to use inheritance.  The diagram in Figure 1 shows you the minimum hierarchy of how the building classes (i.e., Hall, Lab, and Theatre) relate to the Facility class and the Building interface. All buildings (e.g., Halls, Labs, or Theatres) extend the Facility class and implement the

 

Figure 1: The hierarchy of buildings

Building interface.  (Hint: You can introduce additional classes/interfaces to the hierarchy to help with the implementation). Every building class,e.g., Hall, Lab, or Theatre, should have the following properties.

.  level – the current level of the building.  This is represented by an int.

The following table  (Table 1  shows  the maximum level,  the  base capacity and the base building cost for the different building types. We will explain how these base attributes affect the construction of the building later.

Building Type

Max Level

Base capacity

Base building cost (ECScoins)

Hall

4

6

100

Lab

5

5

300

Theatre

6

10

200

Table 1: Buildings and their attributes

To construct and upgrade a building, the following rules apply.

.  The cost for constructing a new building is the base building cost.  For example, to build a new Hall, the university will need to spend  100 ECScoins.   The newly constructed building will be at Level 1.

.  The cost of upgrading a building (assuming that it is not yet at the maximum level) is according to the following formula.

upgradeCost = baseCost  (currentLevel + 1)

For example, to upgrade a Lab from Level 2 to Level 3, the university will need to spend 300  (2 + 1) = 900 ECScoins.

.  The capacity of a building can be computed according to the following formula.

capacity = baseCapacity  2(currentLevel-1)

For example, the capacity of a Theatre at Level 5 is 10  2(5-1)  = 160.  Hint:  You can use java.lang.Math.pow() method.

You can have any additional properties and methods for your classes/interfaces  as you wish.

BY THIS STAGE you should have a package named facilities containing a Facility class,a sub-package named facilities.buildings containing the Building interface, and the sub-classes of Facility implementing Building: Hall, Lab, and Theatre.

You can now test your facility implementation by creating a main method and construct-     ing some objects of these building classes. You can call increaseLevel(), getUpgradeCost(), getLevel(), and getCapacity() to test your implementation.

We provide a test harness for this part.  Information about how to download and use the test harness is at

https://git.soton.ac.uk/tsh2n14/2324-comp1202-ProgrammingI-Coursework/ .