Due - Sunday, October 6, 2024
This is a group project of 2 or 3 students per group. The groups can be found in the document Assignment2_Groups.docx.
A travel simulator simulates the travel of many types of vehicles. The simulator uses certain function calls that all vehicles have to adapt to. The simulator adds fuel to the vehicles and has them travel. The distance, time, fuel level and fuel costs are then reported.
Legacy code exists for three types of vehicles: the boat, the car, and the airplane. Each vehicle has its own functions for adding fuel, travelling, and reporting information. The travel simulator therefore should be able to extract or set information for each of these types of vehicles. The problem is to set and get information in a unified way for all types of vehicles.
You must decide if you are going to use one of the standard design patterns that you have
learned so for, or create a custom one. Either way, you must provide a UML diagram of your
implementation.
You can write your code in one of the following four languages: C++, C#, Java or Python.
Explain your choice, keeping in mind the principles of software engineering regarding
reusability and extentibility. Also keep in mind that at least one of your assignments
has to be written in Java and at least one in C#.
The contemporary travel simulation for a boat, car and airplane assumes each vehicle has a full tank of fuel, and has the boat travelling 100km, the car 1,000km, and the airplane 10,000km. Information is then printed for each. Each vehicle then has fuel added. The boat has 120L of fuel added, the car 40L, and the airplane 50,000L of fuel. Each travels again. The boat travels 100km, the car 1,000km and the airplane 10,000km. Information is then printed for each. Note that although each vehicle uses different function names for getting and setting information, the travel simulator assumes a unified interface.
Code for the travel simulator (which is incomplete) can be found at:
C++: TravelSimulation.cpp,
C#: TravelSimulation.cs,
Java: TravelSimulation.java,
Python: TravelSimulation.py.
Code that contains a vehicle class (which is incomplete) and a function that prints
information for each vehicle (which is incomplete) can be found at:
C++: Vehicle.h and
Vehicle.cpp,
C#: Vehicle.cs,
Java: Vehicle.java,
Python: Vehicle.py.
The travel simulator's main function and the print information function represents the contemporary code. The code for the boat, car, and airplane represent the legacy code.
As you can see from the below code, the legacy boat class has a constant fuel capacity, a constant fuel
consumption rate, a constant fuel cost, and a constant speed. It has a variable fuel level and total
distance travelled. There are functions for adding fuel, for getting the total distance, getting the time
travelled, getting the fuel level, getting the fuel cost, and a function for travelling. Note that
the boat travels at a constant speed and fuel consumption is determined in litres/hour. The
travel simulator will have to get and set values for the boat somehow.
C++: Boat.h and
Boat.cpp,
C#: Boat.cs,
Java: Boat.java,
Python: Boat.py.
As you can see from the below code, the legacy car class has a constant fuel capacity, a constant fuel
efficiency, a constant fuel cost, and a constant speed. It has a variable fuel level and total
distance travelled. There are functions for adding fuel, for getting the total distance, getting the time
travelled, getting the fuel level, getting the fuel cost, and a function for travelling. Note that
the car travels at a constant speed and fuel efficiency is determined in litres/100km. The
travel simulator will have to get and set values for the car somehow.
C++: Car.h and
Car.cpp,
C#: Car.cs,
Java: Car.java,
Python: Car.py.
As you can see from the below code, the legacy airplane class has a constant fuel capacity, a constant fuel
consumption rate, a constant fuel cost, and a constant speed. It has a variable fuel level and total
distance travelled. There are functions for adding fuel, for getting the total distance, getting the time
travelled, getting the fuel level, getting the fuel cost, and a function for travelling. Note that
the airplane travels at a constant speed and fuel consumption is determined in litres/hour. The
travel simulator will have to get and set values for the airplane somehow.
C++: Airplane.h and
Airplane.cpp,
C#: Airplane.cs,
Java: Airplane.java,
Python: Airplane.py.
Once the travel simulator code has been completed and the different vehicle types adapted to the travel simulator, a
sample run should look as follows:
Vehicle Type: Boat Travel Distance: 100km Travel Time: 5 hours Current Fuel Level: 50L Fuel Cost: $169 Not enough fuel to travel 1000km. Travelling 561.798km instead. Vehicle Type: Car Travel Distance: 561.798km Travel Time: 9.3633 hours Current Fuel Level: 0L Fuel Cost: $79.5 Vehicle Type: Airplane Travel Distance: 10000km Travel Time: 12.5 hours Current Fuel Level: 32500L Fuel Cost: $50625 Adding fuel... Fuel overflow, capping at 150L. Vehicle Type: Boat Travel Distance: 200km Travel Time: 10 hours Current Fuel Level: 50L Fuel Cost: $338 Not enough fuel to travel 1000km. Travelling 449.438km instead. Vehicle Type: Car Travel Distance: 1011.24km Travel Time: 16.8539 hours Current Fuel Level: 0L Fuel Cost: $143.1 Vehicle Type: Airplane Travel Distance: 20000km Travel Time: 25 hours Current Fuel Level: 15000L Fuel Cost: $101250
You will be marked out of 10 according to the following:
Does not meet expectations | Satisfactory | Good | Exceeds Expectations | |
---|---|---|---|---|
UML Diagram (2 marks) | Does not meet requirements | Meets the most important requirements | Meets all requirements with minor errors | Meets all requirements with no errors |
Travel Simulator (2 marks) | Does not meet requirements | Meets the most important requirements | Meets all requirements with minor errors | Meets all requirements with no errors |
Boat (1 mark) | Does not meet requirements | Meets the most important requirements | Meets all requirements with minor errors | Meets all requirements with no errors |
Car (1 mark) | Does not meet requirements | Meets the most important requirements | Meets all requirements with minor errors | Meets all requirements with no errors |
Airplane (1 mark) | Does not meet requirements | Meets the most important requirements | Meets all requirements with minor errors | Meets all requirements with no errors |
Code Documentation (1 mark) | Does not contain documentation | Contains header documentation for either all files or for all functions within each file | Contains header documentation for all files and for most functions within each file | Contains header documentation for all files and for all functions within each file. Documents unclear code. |
Questions (2 marks) | Answers no question correctly | Answers some questions correctly | Answers most questions correctly | Answers all Questions correctly |
Please email all source code and answers to questions to: miguel.watler@senecapolytechnic.ca
Your answers to questions can be submitted in a separate document or embedded within your source code.
You will be docked 10% if your assignment is submitted 1-2 days late.
You will be docked 20% if your assignment is submitted 3-4 days late.
You will be docked 30% if your assignment is submitted 5-6 days late.
You will be docked 40% if your assignment is submitted 7 days late.
You will be docked 50% if your assignment is submitted over 7 days late.