Software Engineering 1 EEL5881 Spring 2009. Homework - 2



Similar documents
Using ilove SharePoint Web Services Workflow Action

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

2009 Tutorial (DB4O and Visual Studio 2008 Express)

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

LAB4 Making Classes and Objects

Illustration 1: Diagram of program function and data flow

Moving from CS 61A Scheme to CS 61B Java

Introduction to Object-Oriented Programming

CHAPTER 10: WEB SERVICES

Part I. Multiple Choice Questions (2 points each):

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

CSE 308. Coding Conventions. Reference

CS170 Lab 11 Abstract Data Types & Objects

Chapter 9 Delegates and Events

How To Develop A Mobile Application On Sybase Unwired Platform

Web Services API Developer Guide

J a v a Quiz (Unit 3, Test 0 Practice)

How to create a SMTP plugin for ArGoSoft Mail Server,.NET edition (AMS.NET edition) using Visual Studio 2005

6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Java Crash Course Part I

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

MANJRASOFT PTY LTD. Developing MapReduce.NET Applications. Aneka 2.0. Manjrasoft 10/22/2010

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

A Step by Step Guide for Building an Ozeki VoIP SIP Softphone

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Java Programming Fundamentals

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Introduction to Java

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Web Services in.net (1)

C++ INTERVIEW QUESTIONS

Java Classes. GEEN163 Introduction to Computer Programming

Web development... the server side (of the force)

Crash Course in Java

Appendix B Task 2: questionnaire and artefacts

Java: overview by example

Chapter 14 WCF Client WPF Implementation. Screen Layout

WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

Mapping Specification for DWG/DXF (MSD) C#.NET Code Samples

PhidgetInterfaceKit 8/8/8

Building Java Programs

The C Programming Language course syllabus associate level

Java CPD (I) Frans Coenen Department of Computer Science

public static void main(string[] args) { System.out.println("hello, world"); } }

Java Cheatsheet. Tim Coppieters Laure Philips Elisa Gonzalez Boix

Basic Object-Oriented Programming in Java

EMC Documentum Application Connectors Software Development Kit

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

WRITING DATA TO A BINARY FILE

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output:

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

More on Objects and Classes

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

AP Computer Science Java Mr. Clausen Program 9A, 9B

CS 111 Classes I 1. Software Organization View to this point:

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Software Development with UML and Java 2 SDJ I2, Spring 2010

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

SharePoint Integration

Conexión SQL Server C#

Composing Concerns with a Framework Approach

Object-Oriented Programming in Java

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES

Sample CSE8A midterm Multiple Choice (circle one)

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Save Actions User Guide

The following program is aiming to extract from a simple text file an analysis of the content such as:

Yarmouk University Faculty of Science and Information Technology Department of Computer Information Systems CIS 282 Developing Web Applications

CS506 Web Design and Development Solved Online Quiz No. 01

Introduction to Visual Studio and C#

Implementing a WCF Service in the Real World

DEVELOPING DATA PROVIDERS FOR NEEDFORTRADE STUDIO PLATFORM DATA PROVIDER TYPES

History OOP languages Year Language 1967 Simula Smalltalk

Topic 11 Scanner object, conditional execution

Developing Task Model Applications

CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing

An Incomplete C++ Primer. University of Wyoming MA 5310

Overview of Web Services API

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

AP Computer Science Static Methods, Strings, User Input

Inheritance, overloading and overriding

Install Java Development Kit (JDK) 1.8

How to create/avoid memory leak in Java and.net? Venkat Subramaniam

WEB SERVICES TECHNICAL GUIDE FOR DEVELOPERS

Transcription:

Software Engineering 1 EEL5881 Spring 2009 Homework - 2 Submitted by Meenakshi Lakshmikanthan 04/01/2009

PROBLEM STATEMENT: Implement the classes as shown in the following diagram. You can use any programming language which supports object oriented programming such as Java/C++ for implementation. This is similar to the ticket reservation system described in Homework#1 (you could refer to it if needed) You need to provide an implementation of all the classes. o Every class should have a constructor. o In the constructor function of each class, you need to initialize the private attributes. o Create two different' Customer' objects within a 'Ticket System' where each customer looks for a different band performing. o Seat Assignment is carried out in the SeatAssignment class which finds the band, displays the seating chart and assigns seats. You may need to provide additional functions to carry out necessary operations or provide most functionality within the declared functions. o Once seats are assigned and selected, the checkout process should be initiated. The Ticket System is the primary controlling point of the system. The main objects need to be instantiated here.

SOLUTION The class diagram in the problem is implemented using a console application in C#.Net Following are the classes in the implementation 1. TicketReservationSystem instantiates the Ticket System 2. TicketSystem - instantiates all the main objects of the system 3. SeatingAssingment Composition with TicketSystem. 4. Customer 5. Administrator 6. Billing The implementation of the classes is as follows:

TicketReservationSystem.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the Initiator class of the Console Application which will instantiate the Ticket System public class TicketReservationSystem public static void Main(string[] args) //Instantiates the TicketSystem Class. TicketSystem t = new TicketSystem(); //prints the output of the Ticket System seat assignments to different customers Console.WriteLine(t.SearchBand());

TicketSystem.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the main class of the System, this class instantiates all the main objects of the system public class TicketSystem #region "Variables" private SeatAssignment mseatassignment; private Customer customer1; private Customer customer2; #region "Constructors" public TicketSystem() //Seating Assignment is instantiated and it is passed to every other class in the system. //Thus Ticket System is composed of Seating Assignment mseatassignment = new SeatAssignment(); //Instantiates Administrator and adds a new seat. Administrator admin = new Administrator(ref mseatassignment); admin.updatesystem("10"); //instantiates two new customers customer1 = new Customer("Meenakshi", "4000 Central Florida Blvd, Orlando, FL - 32817", 1234567890); customer2 = new Customer("Aarthi", "123 ABC Avenue, Oveido, FL - 32765", 1232) ; #region "Destructor" ~TicketSystem() //Seating Assignment is destroyed. Seating Assignment cannot exist without ticket system mseatassignment = null; #region "Methods" /// This method searches the seats for each customer for its specified band /// and shows the seating chart and lets the customer accept the seat and /// initiates the checkout process for each customer for the selected seat /// <returns></returns> public string SearchBand() //Customer 1 //search the band for available seats for band "ABC" and assign a seat string seat1 = customer1.searchband(ref mseatassignment,"abc");

TicketSystem.cs //display the seating chart customer1.getseatingchart(ref mseatassignment); 2 //customer accepts the seat customer1.acceptseats(ref mseatassignment, seat1); //initiate the billing and checkout process Billing bill1 = new Billing(customer1); bill1.checkoutprocess(); //Customer 2 //search the band for available seats for band "DEF" and assign a seat string seat2 = customer2.searchband(ref mseatassignment,"def"); //display the seating chart customer1.getseatingchart(ref mseatassignment); //customer accepts the seat customer2.acceptseats(ref mseatassignment, seat2); //initiate the billing and checkout process Billing bill2 = new Billing(customer2); bill2.checkoutprocess(); //returns the seats assigned for each customer return "customer 1 is assigned seat " + seat1 + " for band \"ABC\" and Customer 2 is assigned seat " + seat2 + " for band \"DEF\".";

SeatAssignment.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the seat assignment class, that holds the seats that can be searched for /// each band and assigned to each customer public class SeatAssignment #region "Variables" private string[] seatdetails; private System.Random RandNum; #region "Properties" public string[] SeatDetails get return seatdetails; set seatdetails = value; #region "Constructors" public SeatAssignment() seatdetails = new string[] "1", "2", "3", "4" ; RandNum = new System.Random(); public SeatAssignment(string[] pseatdetails) seatdetails = pseatdetails; RandNum = new System.Random(); #region "Methods" /// finds the available seats and assigns a seat randomly to the customer /// <param name="bandname">name of the band</param> /// <returns>seat Detail</returns> public string FindAvailableSeats(string bandname) int MyRandomNumber = RandNum.Next(0, seatdetails.length - 1); return seatdetails[myrandomnumber]; /// Returns the seating chart /// <returns></returns> public string DisplaySeatingChart()

SeatAssignment.cs string seatingchart=""; for (int i = 0; i < seatdetails.length; i++) seatingchart += seatdetails[i] + ","; seatingchart = seatingchart.trimend(','); return "Seating Chart: " + seatingchart; 2 ///Assigns the seat to the customer for that band and removes it from the availability /// for other customers for that band /// <param name="seatdetails">seat Details</param> /// <returns>assigned Seat</returns> public string AssignSeats(string SeatDetails) return "Seat Assigned: " + seatdetails; /// Adminsitrator Adds new seats to the seat assignment /// <param name="seat">new seat</param> public void UpdateSeats(string Seat) string[] newseats = new string[seatdetails.length + 1]; for (int i = 0; i < seatdetails.length; i++) newseats[i] = seatdetails[i]; newseats[newseats.length - 1] = Seat; seatdetails = newseats;

Customer.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the customer class who searches for seats for a band and buys the ticket public class Customer #region "Variables" private string name; private string address; private int CardNum; #region "Properies" public string Name get return name; set name = value; public string Address get return address; set address = value; public int CardNumber get return CardNum; set CardNum = value; #region "Constructors" public Customer() name = ""; address = ""; CardNum = 0; public Customer(string pname, string paddress, int pcardnumber) name = pname; address = paddress; CardNum = pcardnumber; #region "Methods" /// Searches for a band /// <param name="seatassignment">reference to the SeatAssignment in the TicketSystem</param> /// <param name="bandname">name of the band</param> /// <returns>gets the seat detail from seat assignment</returns> public string searchband(ref SeatAssignment seatassignment, string bandname) return seatassignment.findavailableseats(bandname);

Customer.cs 2 /// Gets the seating chart from the seat asssignment of the Ticket System /// <param name="seatassignment">reference to the SeatAssignment in the TicketSystem</param> public void GetSeatingChart(ref SeatAssignment seatassignment) seatassignment.displayseatingchart(); /// Accepts and reserves the seat /// <param name="seatassignment">reference to the SeatAssignment in the TicketSystem</param> /// <param name="seatdetails">assigned Seat</param> public void AcceptSeats(ref SeatAssignment seatassignment, string SeatDetails) seatassignment.assignseats(seatdetails);

Billing.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the Billing class that initiates the checkout process public class Billing #region "Variables" private Customer customer; #region "Constructors" public Billing() customer = new Customer(); public Billing(Customer pcustomer) customer = pcustomer; /// check out the ticket for the given customer public void CheckoutProcess() verifycard(); /// Does some validatiion of the credit card and returns the result /// <returns>credit Card Validation result</returns> private bool verifycard() if (customer.cardnumber!= 0) return true; else return false;

Administrator.cs using System; using System.Collections.Generic; using System.Text; 1 namespace TicketReservationSystem /// This is the administrator class /// who adds new seats to the seating assinment of the Ticket System public class Administrator //Seat Assignment of the TicketSystem private SeatAssignment seating; #region "Constructors" public Administrator(ref SeatAssignment seat) seating = seat; /// Adds new seat to the seating Assignment /// <param name="seat">seat Details for the new seat</param> public void UpdateSystem(string seat) seating.updateseats(seat);

PROGRAM OUTPUT