Assignment 1 – Software Engineering 2
Question 1
In an organization, a team of salespersons has the following structure. Managers, supervisors, and salespersons are all taking the responsibility to sell the company products. Manager may have other managers, supervisors, and salespersons as his/her subordinates. Supervisor may have other supervisors and salespersons as his/her subordinates. Salesperson has no subordinate. Manager get 2% of his/her total sales; Supervisor get 3% of his/her total sales; Salesperson get 4% of his/her total sales. You are required to develop a software to calculate the total sales commission for the entire sales team. To improve coding quality, you are required to include the most suitable design pattern in your code. You can use pseudo for this assignment but important elements such as the relationships between classes and the functions to fulfill the requirements have to be clearly shown.
Question 2
A soda drink company own hundreds of dispensers in the town. They have developed software classes to help maintaining the dispensers distributed across the town. One of the features is to pull the state of all dispensers. Due to the number of the dispensers and the overhead of network connection to each dispenser, the operation of pulling dispensers’ state take a long time to complete. It is not viable to pull the state information every time someone need it. The company decided that after the first time the states information is pulled from all the dispensers, it should be cached and keep it valid for the next 3 hours. After 3 hours if anyone need the states information, a new pull process should start again. You are required to design an add-on code to satisfy the company’s new decision. You should use the available design pattern that satisfy the requirement at the same time minimize the disruption to the existing code.
Question 3
In a development of a computer game software, you are required to develop several classes to represent different type of robots. The robots are able to attack its enemy using different type of weapon depending on the characteristics of the enemy. If the enemy has armor greater than 50 points, the robot should use Laser. If the armor is between 20 and 50 points, Rifle is good enough. If the armor is less than 20, Spear is the one to pick. The choice of weapon should also consider the speed of the enemy. If the enemy’s speed is faster than 60km/h, Spear will not yield any damage. If the enemy move faster than 120km/h, the only effective weapon will be Laser.
In your client program, create 10 robot objects. They should be any random type of robots between Double Blades, Mumby Bot, Charm Sniper, and Khan Warrior. Equip the robots with appropriate weapon.
Design your program with Bridge design pattern in mind. In term of the creation of the weapon object, you should consider the use of an appropriate creational design pattern. In this exercise, you are expected to use the mix of design pattern. Draw a UML representing the mixture of your chosen design pattern and write pseudo code for the exercise.