C# Assignment

profileBrad.rs
assignment_1_start_up_classes.zip

Customer.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Original { 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; } } }

FedUniCruises.cs

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Original { class FedUniCruises { Ship ship1; public FedUniCruises() { this.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.ToLower().Equals("a")) cabins = ship1.GetDeck("Balcony Suite"); else if (cabinclass.ToLower().Equals("b")) cabins = ship1.GetDeck("Suite"); else if (cabinclass.ToLower().Equals("c")) cabins = ship1.GetDeck("Deck 3 - Outside Twin"); else if (cabinclass.ToLower().Equals("d")) cabins = ship1.GetDeck("Deck 2 - Outside Twin"); else if (cabinclass.ToLower().Equals("e")) cabins = ship1.GetDeck("Deck 1 - Outside Twin"); else if (cabinclass.ToLower().Equals("f")) cabins = ship1.GetDeck("Deck 3 - Inside Twin"); else if (cabinclass.ToLower().Equals("g")) 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; } static void Main(string[] args) { FedUniCruises bookings = new FedUniCruises(); Customer jd = new Customer("Johnny", "Depp", "A100356"); Reservation booking = bookings.BookPassage("C", jd, 2); Console.WriteLine ("Johnny's booking costs = " + booking.cost); Console.Write ("Cabins booked are: "); ArrayList cabins = booking.cabins; for(int i = 0; i < cabins.Count; i++) { Console.Write (((room)cabins[i]).number + "\t"); } Console.ReadLine(); } } }

Reservation.cs

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Original { class Reservation { Customer booker; 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); } } }

room.cs

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

Ship.cs

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Original { 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]; } } }

Assignment 1 - 2016-07.docx

ITECH 3201 Software Engineering: Analysis and Design

Assignment 1

Overview

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 for 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” discussed by Fowler.

Timelines and Expectations

Percentage Value of Task: 20%

Due: 16:00 Friday, 6-5-2016 (week 7)

Minimum time expectation: 10-15 hours

Learning Outcomes Assessed

Knowledge:

K1.

explain the significance of detailed project planning and control, good communication and documentation and the use of appropriate tools in order to provide a quality product;

K2.

discriminate between software engineering and programming, and thus the distinction between a software configuration and a program;

Skills:

S2.

analyse source code and develop comprehensive unit test suites

S3.

operate CASE software to document the design of a piece of software

S4.

apply refactoring to identify poor programming practice in existing source code and improve its structure and readability

Assessment Details

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 for 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” discussed by Fowler.

Notes about the assignment

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)

Requirements

· Report detailing any “code smells” present in the code and how you intend to refactor them out of the code

· A refactored version of the system eliminating all identified code smells

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

· A sequence diagram illustrating how the final refactored system processes a new booking

· Extensive NUnit tests for methods SetupShip and BookPassage in the FedUniCruises class

· 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, while gold members receive 10% off the cost of their bookings.

· Add a platinum membership to the loyalty rewards program which entitles the holder to 50% off the cost of booking on decks 1, 2 and 3 and 25% off the cost of bookings for all suites.

Submission

You are required to submit to on Moodle before the due date a zip file containing:

· A solution called final which has all of the final refactored code and the project for the unit tests

· The accompanying Enterprise Architect file with model versions of the original (that you started with) and final code projects.

· A word document containing your UML models and a justification of your refactorings.

Marking Criteria/Rubric

Task

Criteria

Range

Marks

Report detailing “code smells”

· Covers most code smells clearly and accurately

· description of appropriate refactoring to address these smells

· description of how these refactorings will be implemented

4 – 5

· Covers the basic codes smells

· some refactorings not appropriate or not explained clearly

2 - 3

· Not many codes smells identified

· explanations not clear

· appropriate refactorings not identified or explained

0 - 1

Refactored version of the system

· All refactorings implemented correctly

· coding standards adhered to

· no syntax errors

4 - 5

· Most refactorings implemented correctly

· minor misconceptions or errors

· no syntax errors

2 - 3

· Refactorings not implemented correctly

· syntax errors present

· programming standards not adhered to

0 - 1

Class diagrams

· All classes represented

· operations and attributes present

· correct aspect specifications

· appropriate connections between classes

2

· Not all classes represented

· some operations and attributes missing

· other errors

0 - 1

Sequence diagram

· Objects and messages represented correctly and properly sequenced

1

· Marks deducted for errors or misconceptions

0 – ½

NUnit tests

· Tests covering a wide of the possible outcomes for all methods

· Proper coding standards adhered to

· Init method used if necessary

· No syntax errors

3

· All methods tested to a basic level

· Minor omissions or misconceptions

· Coding standards adhered to

· No syntax errors

2

· Not all methods tested or contain errors

· Major misconceptions or syntax errors

· Sloppy coding

0 - 1

Loyalty rewards system

· Loyalty rewards system completely implemented and integrated into main system.

· Coding standards adhered to

· No errors present

2

· Loyalty rewards system not completely implemented or contains errors

· Codings standards not adhered to

· Syntax errors presents

0 - 1

Platinum rewards system

· Loyalty rewards system completely implemented and integrated into main system.

· Coding standards adhered to

· No errors present

2

· Loyalty rewards system not completely implemented or contains errors

· Codings standards not adhered to

· Syntax errors presents

0 - 1

Feedback

Assignments will be marked within 2 weeks. Marks will be made available on FDL Grades. Feedback will be provided in electronic form on Moodle.

Plagiarism:

Plagiarism is the presentation of the expressed thought or work of another person as though it is one's 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. More information about the plagiarism policy and procedure for the university can be found at http://federation.edu.au/students/learning-and-study/online-help-with/plagiarism.

CRICOS Provider No. 00103D

Assignment 1 - 2016-07.docx

Page 1 of 4

CRICOS Provider No. 00103D

Assignment 1 - 2016-07.docx

Page 4 of 4

image1.jpeg

image2.jpeg