C++ start up code and specifications are there.

profileprabhdeep
attachments_2015518.zip

ITECH3201-7201 Assignment 1 - Mt Helen.docx

ITECH3201-7201

Assignment 1 – Teaching Period 1, 2014

Marks: 20

(7201 students complete tasks which sum to 24 which then gets converted into a mark out of 20)

Due: As per course description

Type: Individual Task

Disclaimer

You must use the code supplied by your tutor. Do not use code given to you by another student (or past student) as the codebase will be different and you will be awarded ZERO MARKS for the assignment task.

Description

· You are required to document, test and refactor an existing application.

You will be given a copy of an existing C# application which is responsible taking bookings for a cruise ship, this application is badly in need of refactoring and even a casual viewing of the source code reveals many examples of the “code smells” talked about in Fowler’s book.

The base application consists of several classes – Customer, Reservation, room, Ship, and UBCruises. There is also a file called Program.cs that contains the Main method.

Some notes about the application:

· There are eight types of cabin which may be booked, standard costs are as follows:

· Balcony Suite ($5000 per cabin)

· Suite ($4000 per cabin)

· Deck 3 - Outside Twin ($3500 per cabin)

· Deck 2 - Outside Twin ($3400 per cabin)

· Deck 1 - Outside Twin ($3300 per cabin)

· Deck 3 - Inside Twin ($3400 per cabin)

· Deck 2 - Inside Twin ($3300 per cabin)

· Deck 1 - Inside Twin ($3200 per cabin)

Step 1 – Rename the base code

1. Download the code from Moodle and unzip it in the filesystem

2. Rename the base folder to “Assignment 1 – yourid” (your id equals your student number)

3. Open the solution up in Visual Studio right click on the Solution and rename it as per (2)

4. Build the solution and inspect the output, now spend some time getting to know the code before you do anything else.

Step 2 – Identify “code smells”

Open up a new document in Word (or equivalent), start jotting down any code smells you identify in the code in point form (you might want to cut and paste the code into word to illustrate the problems).

Step 3 – Create a class diagram of the initial code.

Do this in Enterprise Architect and copy the resultant diagram into your word file. Ensure your EA file is saved and labelled as “starting code base”

Step 4 – Start refactoring and developing your unit tests

Ensure that your starting code and EA file is backed up, and once this is done jump back into Visual Studio and get to work refactoring.

Your final code should be fully refactored and have unit tests developed for every method (other than ToString and Get and Set methods).

Marking Criteria

This assignment consists of a number of tasks for you to perform as detailed in the following:

· (5 marks) A report describing any “code smells” present in the starting code, and an explanation how you intend to refactor them out of the application.

· (5 marks) A refactored version of the system eliminating all identified code smells present in the initial code

· (5 marks) Unit tests for all methods excluding ToString, Get and Set methods

· Contained in an Enterprise Architect File and your report

· (2 marks) A class diagram illustrating the initial code and another class diagram illustrating the final refactored code (including all relevant dependencies).

· (2 marks) A sequence diagram illustrating how the final refactored system processes a new booking.

· (1 mark) A visual studio solution containing your completed Lab 1 code fully unit tested.

· ITECH7201 Students Only (4 marks) Add further functionality including:

· (2 marks) Add a loyalty rewards system. People who are bronze members of the loyalty rewards program receive a 5% discount on all bookings, people who are silver members receive 7.5% discount on all bookings whilst gold members receive 10% off the cost of their bookings.

· (2 marks) As an added test add a platinum membership to the loyalty rewards program which entitles the holder to 50% of the cost of booking on decks 1,2 and 3 and 25% off the cost of bookings for all suites.

Submit

You are required to submit the assignment before the due date consisting of:

· A Zip file containing the following (submitted via Moodle under the Assignment 1 link)

· All code representing your refactored application and Unit tests

· The accompanying Enterprise Architect file with model versions that correspond to your final code submission.

· An electronic report, in MS-Word, containing your UML, identification of any problems with the initial code, and an explanation of your Refactorings.

Plagiarism

This is an individual assignment you are not to attempt this assignment (or any part thereof) in conjunction with any other parties. All work handed in for marking should be your own and any help received should be explicitly acknowledged.

It is important to learn from the work of others and you are encouraged to explore the library, World Wide Web resources and have discussions with other students. However, work for assessment must be entirely the student's own work.

Plagiarism is the presentation of the expressed thought or work of another person as though it is ones own without properly acknowledging that person.

You must not allow other students to copy your work and must take care to safeguard against this happening. In cases of copying, normally all students involved will be penalised equally; an exception will be if you can demonstrate the work is your own and you took reasonable care to safeguard against copying.

Plagiarism is a serious offence. As set out in the University Regulation 6.1.1. Students who are caught plagiarising will, for a first offence, be given a zero mark for that task. A second offence will result in a failing grade for the Unit(s) involved and any subsequent offence will be referred to the Student Discipline Committee.

CRICOS Provider No. 00103D

Insert file name here

Page 1 of 3

CRICOS Provider No. 00103D

Insert file name here

Page 3 of 3

Assignment1-2014-startup-code.7z

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/bin/Debug/Assignment1-2014.mp3

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/Assignment1-2014.mp3

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/bin/Debug/Assignment1-2014.vshost.mp3

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Properties/AssemblyInfo.cs

using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Assignment1-2014")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("University of Ballarat")] [assembly: AssemblyProduct("Assignment1-2014")] [assembly: AssemblyCopyright("Copyright © University of Ballarat 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("2ab846e0-39fd-40f2-b065-cc3a5fbdd345")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Customer.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { public class Customer { int discount = 1; String lastname, firstname; String accountNumber; public Customer(String firstname, String lastname, String accountNumber) { this.firstname = firstname; this.lastname = lastname; this.accountNumber = accountNumber; } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Program.cs

using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { class Program { static void Main(string[] args) { UBCruises bookings = new UBCruises (); Customer cust1 = new Customer ("Fred", "Johnstone", "A100356"); Reservation booking = bookings.bookPassage("C", cust1, 2); Console.WriteLine ("Cust1's booking costs = {0}", booking.cost); Console.Write ("Cabins booked are: "); ArrayList cabins = booking.cabins; for (int i = 0; i < cabins.Count; i++) Console.Write ("{0}\t", ((room) cabins[i]).number); Console.WriteLine(); Console.WriteLine(); Customer cust2 = new Customer("Jane", "Jackson", "M892039"); Reservation booking2 = bookings.bookPassage("H", cust2, 4); Console.WriteLine("Cust2's booking costs = {0}", booking2.cost); Console.Write("Cabins booked are: "); cabins = booking2.cabins; for (int i = 0; i < cabins.Count; i++) Console.Write("{0}\t", ((room)cabins[i]).number); Console.WriteLine(); Console.ReadLine(); } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Reservation.cs

using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { public class Reservation { public Customer booker; public Boolean confirmed = true; public int cost; public ArrayList cabins = new ArrayList(); public Reservation(Customer booker, Boolean confirmed) { this.booker = booker; this.confirmed = confirmed; } public Reservation(Customer booker, int cost, ArrayList cabins) { this.booker = booker; this.cost = cost; this.cabins = cabins; } public Reservation(Customer booker, int cost, room theCabin) { this.booker = booker; this.cost = cost; cabins.Add(theCabin); } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/room.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { public class room { public int fare; public String number; public Boolean booked = false; public room(int fare, String number) { this.fare = fare; this.number = number; } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Ship.cs

using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { public class Ship { Dictionary<String, ArrayList> cabins = new Dictionary<String, ArrayList>(); String name; public Ship(String name) { this.name = name; } public void addDeck(String deckName, ArrayList cabins) { this.cabins.Add(deckName, cabins); } public ArrayList getDeck(String deckName) { return (ArrayList)cabins[deckName]; } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/UBCruises.cs

using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_2014 { public class UBCruises { Ship ship1; public UBCruises() { setupShip(); } public void setupShip() { ship1 = new Ship("Olympic Countess"); ArrayList groupA = new ArrayList(); for (int i = 0; i < 10; i++) { groupA.Add(new room(5000, "A" + (i + 1))); } ArrayList groupB = new ArrayList(); for (int i = 0; i < 10; i++) { groupB.Add(new room(4000, "B" + (i + 1))); } ArrayList groupC = new ArrayList(); for (int i = 0; i < 30; i++) { groupC.Add(new room(3500, "C" + (i + 1))); } ArrayList groupD = new ArrayList(); for (int i = 0; i < 36; i++) { groupD.Add(new room(3400, "D" + (i + 1))); } ArrayList groupE = new ArrayList(); for (int i = 0; i < 40; i++) { groupE.Add(new room(3300, "E" + (i + 1))); } ArrayList groupF = new ArrayList(); for (int i = 0; i < 30; i++) { groupF.Add(new room(3400, "F" + (i + 1))); } ArrayList groupG = new ArrayList(); for (int i = 0; i < 36; i++) { groupG.Add(new room(3300, "G" + (i + 1))); } ArrayList groupH = new ArrayList(); for (int i = 0; i < 40; i++) { groupH.Add(new room(3200, "H" + (i + 1))); } ship1.addDeck("Balcony Suite", groupA); ship1.addDeck("Suite", groupB); ship1.addDeck("Deck 3 - Outside Twin", groupC); ship1.addDeck("Deck 2 - Outside Twin", groupD); ship1.addDeck("Deck 1 - Outside Twin", groupE); ship1.addDeck("Deck 3 - Inside Twin", groupF); ship1.addDeck("Deck 2 - Inside Twin", groupG); ship1.addDeck("Deck 1 - Inside Twin", groupH); } public Reservation bookPassage(String cabinclass, Customer booker, int number) { ArrayList cabins; if (cabinclass.Equals("a", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Balcony Suite"); else if (cabinclass.Equals("b", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Suite"); else if (cabinclass.Equals("c", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Deck 3 - Outside Twin"); else if (cabinclass.Equals("d", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Deck 2 - Outside Twin"); else if (cabinclass.Equals("e", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Deck 1 - Outside Twin"); else if (cabinclass.Equals("f", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Deck 3 - Inside Twin"); else if (cabinclass.Equals("g", StringComparison.OrdinalIgnoreCase)) cabins = ship1.getDeck("Deck 2 - Inside Twin"); else cabins = ship1.getDeck("Deck 1 - Inside Twin"); if (available(cabins, number)) { ArrayList bookedcabins = new ArrayList(); int currentCabin = 0; int cost = 0; while (number > 0) { room thisCabin = (room)cabins[currentCabin]; if (!thisCabin.booked) { bookedcabins.Add(thisCabin); cost += thisCabin.fare; number--; } currentCabin++; } return new Reservation(booker, cost, bookedcabins); } else return new Reservation(booker, false); } public Boolean available(ArrayList cabins, int number) { int freeCount = 0; for (int i = 0; i < cabins.Count; i++) { if (!((room)cabins[i]).booked) freeCount++; } return number <= freeCount; } } }

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/Assignment1-2014.csproj

Debug AnyCPU {ECDE9687-8086-4F78-9201-AF663AE28F1D} Exe Properties Assignment1_2014 Assignment1-2014 v4.5 512 AnyCPU true full false bin\Debug\ DEBUG;TRACE prompt 4 AnyCPU pdbonly true bin\Release\ TRACE prompt 4

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014.sln

Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assignment1-2014", "Assignment1-2014\Assignment1-2014.csproj", "{ECDE9687-8086-4F78-9201-AF663AE28F1D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {ECDE9687-8086-4F78-9201-AF663AE28F1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ECDE9687-8086-4F78-9201-AF663AE28F1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {ECDE9687-8086-4F78-9201-AF663AE28F1D}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECDE9687-8086-4F78-9201-AF663AE28F1D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/Assignment1-2014.csproj.FileListAbsolute.txt

c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\bin\Debug\Assignment1-2014.exe.config c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\bin\Debug\Assignment1-2014.exe c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\bin\Debug\Assignment1-2014.pdb c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\obj\Debug\Assignment1-2014.exe c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\obj\Debug\Assignment1-2014.pdb c:\users\psmith\documents\visual studio 2012\Projects\Assignment1-2014\Assignment1-2014\obj\Debug\Assignment1-2014.csprojResolveAssemblyReference.cache

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/bin/Debug/Assignment1-2014.pdb

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/Assignment1-2014.pdb

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/Assignment1-2014.csprojResolveAssemblyReference.cache

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/App.config

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/bin/Debug/Assignment1-2014.exe.config

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/bin/Debug/Assignment1-2014.vshost.exe.config

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014.v11.suo

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

Assignment1-2014-startup-code/Assignment1-2014/Assignment1-2014/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs