Implementation of STARS System for Wayward Asteroids Resort
Answered
Background
In a galaxy far away. the STAR organisation manages a number of resorts offering space travel and recreation facilities. These resorts always consist of a number of worlds offering different leisure facilities. Each world is connected by shuttles to some of the other worlds at the resort. A card must be used to take a shuttle to journey to another world. Credits can be bought for cards and these are used when making a shuttle journey. However, there are a number of conditions which need to be met before anyone (card) can use a card for a shuttle journey.
Recently, a number of incidents have occurred, which have convinced STAR that they need a better control system: someone who needed to be contacted urgently could not be located, a number of people were able to shuttle to worlds to which they were not entitled, and the Health & Safety Council is concerned about STAR’s ability to ensure safety in the event of a major incident. This project will initially be implemented at the Wayward Asteroids Resort
- Display details of the whole resort
- List all cards on all worlds of the resort
- List all cards currently on a specified world
- Find the current location of a card
- Authorise a shuttle journey, if it meets the required conditions
- Top up a card’s credits
- Convert points to credits
- Record an emergency move of a card (person) back to the home world
- Record the evacuation of all cards (persons) to the home world.
- Card – used for moving around the resort using shuttles
Information stored about cards includes: a card ID number, name, a luxury rating, number of credits and the number of loyalty points. The Card class has a constructor which uses appropriate parameters to set field values and sets the number of loyalty points to zero. The luxury rating (1 to 10) determines the worlds which the person is allowed to visit e.g. a card with a rating of 3 is allowed to visit to all worlds rated 3 or below. Each shuttle journey will deduct 3 credits and adds 2 loyalty point. People may top up their credits at any time. (Handling payments for tis is outside the scope of this project, just trust payment has been made). A person may convert their loyalty points to credits - 4 loyalty points = 1 credit.
Each world has a number, a name, a rating and a capacity (the maximum number of people (cards) that can be on the world at any one time). Each world should maintain a collection of cards currently on that world. These collections should be updated whenever a card enters or leaves a world, so that it is always possible to say who is currently on a world and to find the location of a person as specified by their card
Each shuttle has a journey code and connects a source world to a destination world. It represents a journey in one direction only. To make a shuttle journey, certain conditions must be met. If these conditions are met, the system allows the person with the card onto the shuttle to travel to the destination world. It updates its records to show that a card has left the source world and has travelled to the destination world. It also updates the card's credits and other information, as appropriate.
People will be tracked using their cards
A request by a person with a card to make a shuttle journey will produce one of the following results:
- Successful entry, because ALL of the above conditions are true
- The card's luxury rating is higher or equal to the rating of the destination world.
- The card has enough credits for the journey
- The arrival of the card would NOT exceed the maximum capacity of the destination world.
- The card is listed in the source world of the shuttle
These conditions can be handled by the shuttle, the card, or the worlds
- Refusal to enter the shuttle, because one or more of the above conditions are false
Each resort has a network of worlds joined by one-way shuttles. It also has a a collection of cards. A resort must always have a “Home” world which stores all. Its name MUST be "Home" and it MUST have a rating of 0 and a large maximum capacity. All cards registered at a resort are initially added to this “Home” world.
For the purpose of this coursework, we are not concerned with the wider financial aspects of buying credits. A new card arriving or leaving the resort is also outside the scope of this assignment
Produce a BlueJ project implementing a version of STARS by completing tasks described below. Your project must be capable of running correctly on the software used in UH labs.
Your STARS project should display the qualities associated with good program design:
- Your system should minimise code duplication and be modularised so that components have low coupling and high cohesion. So you will be expected to use inheritance, abstract classes and interfaces.
- You should aim to make your code reusable and easy to maintain.
- Program code should be well documented, displaying both agreed standards of internal documentation.
- Marks shown for each task include marks for both functionality and design.
- Your project must compile. Code which does not compile may be included as comments
- You must attend the online timed demo session. If you do not do the demo session, you get ZERO marks.
- Class Card should have:
- The fields described above
- A constructor to set fields values, using parameter values if required
- Assessors to return the rating and the number of credits, at least
- Methods to add or deduct credits, and to covert loyalty points to credits
- Also methods which return a boolean saying whether
There are enough credits to make a shuttle journey
A parameter is the same as the card id
- A toString() method returning a String with all relevant information about the card
- Class CardTester
- Which will have a main() in which you wil
NOTE: there is no need for any user input or menus or functions, Just a simple sequential tests as shown in L15 & L16 for the Dispenser and the StockItem classes
There is NO need to write tester classes for these class, but you could try to Bench Test them
- Class World should have
- The fields described above. (But just start with the basic fields and add the collection later)
- A constructor to create a world with suitable parameters
- an accessor to return its rating
- An ArrayList field to store Card object references.. (declared and created)
- mutates enter() and leave() which have a Card as a parameter and add/delete is from the Array List
- An accessor which either says whether the world is full (reached capacity) (or still has capacity)
- A method to list all the Cards currently on the world
- An accessor which returns a boolean saying whether a card is on the world (in the ArrayList)
- A toString () method
- This is a basic list and you may need to add some more if required
- Suitable fields as specified above.
- A suitable range of accessors/mutators to process data held by the class
- Method which returns a boolean saying whether Card passed as a parameter can travel ton the shuttle
- A method to process a card travelling to the destination world;
If the card meets the conditions make suitable deductions/additions to the card, add it to the destination world and delete from the source world, and return a suitable message
If it does not meet one of the conditions, return a suitable message and do NOT move it
- A method toString()which returns a String representation of an object of that class.
Without these classes you will find it difficult to develop the remaining classes. Yout may add further fields/methods as to these classes if you require them during further developmen development progresses
- You are expected to provide fields and the code for the methods listed.
- You must NOT change the signatures of the methods listed - you will be penalised
- You may add methods but these must have the modifier private, so
- Cannot be used in client classes
- Most of the methods in this class should they call the methods in the on objects of the lower classes
- Your methods should NOT deal with any input/output
- The name of a location
- Collection of all cards, all worlds and all shuttles
- The collection of all worlds should be an Arraylist where the position of the world in the Array List is the same as its number i.e. “Home” should be at ArrayList location 0.
- set the location of the resort from a parameter value
- Then call the three private methods defined at the end of the class to implement the Wayward Resort described in Appendix A (below)
- load Cards - should create all cards and add them to their collection
- load Worlds - should create all the worlds in and add them to the collection of all worlds. These should be added in the order of their numbers
- setup Shuttles – should create all shuttles and add them to their collection
- Finally, the constructor should add all of the cards to the “Home” world
- [3 private methods to return each type of object (shuttle, card, world) using its key may be useful]
- The largest portion of marks in this task are for the methods: canTravel() and travel()
- Class ResortUI
- This is the class which provides an application for the user
- Only this class and the Tester in Task 5 should use System.out.println
- This is the only class which has input
- Some of the code has been written for you
- You should provide the remaining code
- However, only option 1 - 6 are required for the demo
- The remaining options are related to Task 6 which provide some challenges for those who want to get really high marks. If you have not completed Tasks 1 - 6, to a reasonable level, your attempts to so Task 7w ill not be accepted
You can test your code by running the ResortUI but you will eventually find this tedious. So:
- Provide a Tester class which declares a variable of class ResortManager. to represent the Wayward Asteroids resort.
- Your Tester class must contain a doTest() method which calls appropriate methods on the Resort Manager variable in a way which tests this class and demonstrates that it works according to specification. This method should include appropriate output to the terminal window. Use comments to explain what is being tested.
- Other than Tester and the CardTester in Task 1, you should NOT write testers for the other classes
- The class should have a main() to make it runnable but need not use functions
- the appropriate choice of data,
- The sequencing of method calls
- Explanations of tests.
We are looking for evidence of a systematic approach to testing and will expect you to show that you have identified and tested for the main events likely to occur when the system is running. At this stage, you may ignore the situation where a card visits a world but has insufficient credits to return to the "Home" world.
- A visually neat and readable UML-style class diagram of your system in BlueJ
- Program code should be well documented, displaying both agreed standards of internal documentation and good use of the facilities available in Javadoc. No need for detailed comments on internal method code (ResortManager is already well documented)
These tasks are designed to provide additional challenge. You will only get marks for this task if you complete tasks - 5 to a reasonable level and a specific task at the demo
- Add the following methods to the ResortManager class.
- TopUpCredits – to add credits to a specified card
- move Home - to move a card directly to the Home world without using shuttles or losing credits
- convert Points - to convert a business card's loyalty points to credits
- evacuate All- to move all cards back to the Home world
- Add code in the ResortUI class to implement menu options 7 – 9
At a designated time AFTER the designated assignment hand-in ( to be announced) , you will be asked to demonstrate that you have a good working knowledge of the code that you submitted. This will require you to have remote access to Studynet and BlueJ at a specified time. You will be asked to download your assignment and a written demo specification. In a timed window of 1 hour, you will be asked to make the specified changes and upload your amended code to the Demo assignment slot.
The main purpose of the demonstration is to authenticate your code by showing that you know it well enough to use it and make these changes. If you do not undertake this demonstration , your assignment will get ZERO marks.
- To amend ResortManager to create a resort with small changes to the Wayward World Resort
- write a demo class to test the functionality of your system
Marks for the demonstration will be for code which performs the specified tasks, not for producing correct output.