Exercise 2 Introduction to C# CIS-2320. 2 Create a class called Employee that contains the following private instance variables: Social Securitystring.

Slides:



Advertisements
Similar presentations
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Advertisements

Logic & program control part 3: Compound selection structures.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
For use of IST410 Students only Arrays-1 Arrays. For use of IST410 Students only Arrays-2 Objectives l Declaring arrays l Instantiating arrays l Using.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
CS102--Object Oriented Programming Lecture 6: – The Arrays class – Multi-dimensional arrays Copyright © 2008 Xiaoyan Li.
1 Data Structures Data Structures Topic #2. 2 Today’s Agenda Data Abstraction –Given what we talked about last time, we need to step through an example.
This demo shows how to create a simple multiple choice exercise using drop down menu boxes with the forms tool within MSWord.
1.
Introduction to Classes and Objects (Through Ch 5) Dr. John P. Abraham Professor UTPA.
Functions Parameters & Variable Scope Chapter 6. 2 Overview  Using Function Arguments and Parameters  Differences between Value Parameters and Reference.
1 CSC 222: Computer Programming II Spring 2005 Stacks and recursion  stack ADT  push, pop, peek, empty, size  ArrayList-based implementation, java.util.Stack.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
Data Structures: CSCI 362 – Stack Implementation Data Structures: CSCI 362 – Stack Implementation lecture notes adapted from Data Structures with C++ using.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
11 Chapter 5 METHODS CONT’D. 22 MORE ON PASSING ARGUMENTS TO A METHOD Passing an Object Reference as an Argument to a Method Objects are passed by reference.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
GENERIC COLLECTIONS. Type-Wrapper Classes  Each primitive type has a corresponding type- wrapper class (in package java.lang).  These classes are called.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation.
CS1101: Programming Methodology Recitation 6 – Arrays and Collections.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 2 – Classes and objects.
The switch Statement.  Occasionally, an algorithm will contain a series of decisions in which a variable or expression is tested separately for each.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
ArrayList Class An ArrayList is an object that contains a sequence of elements that are ordered by position. An ArrayList is an object that contains a.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CREATING MENUS IN JAVA Mimi Opkins CECS 174. Menus Menus work well for console applications. The menu can be contained within a do-while loop and the.
Exercise 1 Introduction to C# CIS Code the C# program to prompt the user to key in 12 integer values from the keyboard. If a value containing.
Chapter 3A Strings. Using Predefined Classes & Methods in a Program To use a method you must know: 1.Name of class containing method (Math) 2.Name of.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Chapter One Lesson Three DATA TYPES ©
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class.
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
 CSC111 Quick Revision. Problem Write a java code that read a string, then show a list of options to the user to select from them, where:  L to print.
Java: Variables and Methods By Joshua Li Created for the allAboutJavaClasses wikispace.
Exercise 6 Introduction to C# CIS Create a class called ParseDates that will parse a formatted string containing a date into separate integers.
Chapter 8 Slides from GaddisText Arrays of more than 1 dimension.
Arrays (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
Linked Lists A formal data structure. Linked Lists Collections of data items “lined up in a row” Inserts and deletes can be done anywhere in the list.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
A CLASS CONSISTS OF VARIABLES,
MT262A Review.
Examples of Classes & Objects
Quiz # 02 Design a data type Date to hold date
ARRAYLIST AND VECTOR.
An Introduction to Java – Part I
Chapter 10: An Array Instance Variable
Control Statement Examples
Chapter 4 Unordered List.
CSC 113 Tutorial QUIZ I.
Classes & Objects: Examples
Chapter 8 Slides from GaddisText
Sorts on the AP Exam Insertion Sort.
Assignment 7 User Defined Classes Part 2
Class Examples.
CIS 199 Final Review.
Chapter 2 : List ADT Part I – Sequential List
Web Design & Development Lecture 6
Program: Mini Phone Book 2/11/2016
Objects with ArrayLists as Attributes
The List Container and Iterators
Presentation transcript:

Exercise 2 Introduction to C# CIS-2320

2 Create a class called Employee that contains the following private instance variables: Social Securitystring Namestring Payfloat Typechar(‘H’= Hourly ‘S’ = Salaried) Provide three constructors: Employee() Employee(string s, string n, float p, char t); Employee(Employee e); Provide read-only properties for each instance variable. Provide a Display() method to display all the instance variables on one line.

3 In order to store and process objects of the type Employee create a class called Employees. This class uses a instance of the ArrayList class to store Employee objects. It also provides the following methods to process the employees: public Employees() Creates an instance of ArrayList public void AddSalariedEmployee() This method prompts the user to enter the data for a salaried employee, creates an instance of the Employee class, and inserts the new employee into the ArrayList object in order to keep the objects in sequence by social security number. Make sure there are no duplicates. public void AddHourlyEmployee() This method prompts the user to enter the data for a salaried employee, creates an instance of the Employee class, and inserts the new employee into the ArrayList object in order to keep the objects in sequence by social security number. Make sure there are no duplicates.

4 public void ListAllEmployees() This method produces a listing of the employees currently in the ArrayList object. It should be in social security number sequence. If the list is empty, display a message to that effect private bool Find_Employee( string s) This method searches the ArrayList to try and find the Employee object with the social security number passed as an argument. It returns true if found otherwise false. public void DisplayEmployee() This method prompts the user to enter a social security number and attempts to find that employee in the ArrayList (using the above method). If found, call the Display() method of the Employee object otherwise display a not found message. public void DeleteEmployee() This method prompts the user to enter a social security number and attempts to find that employee in the ArrayList. If found, remove the Employee object from the ArrayList. Make sure only existing employees are deleted.

5 public void ListByName() (Extra 3 points) This method sorts the ArrayList in sequence by employee name and displays the employees currently in the ArrayList. Do not change the current order of the employees (social security number sequence) in the ArrayList.

6 Create a Menu class with a default constructor that creates an object of the type Employees. Also provide the following methods: private void Choices() This method displays a menu and obtains the user’s selection. For example: What is the desired option? 1 = Add hourly employee 2 = Add salaried employee 3 = Display employee 4 = Delete employee 5 = List all employees 6 = Exit public void Process() This method calls the Choices() method above to display the menu and obtain the user’s selection. It then passes control to the appropriate method of the Employees object (add hourly employee, add salaried employee, display an employee, list all employees, and delete an employee). Stay in this function until the user enters a ‘6’.

7 Create a test class called Exercise2. The Main() method should look as follows: static void Main(string[] args) { Menu EmpMenu = new Menu(); EmpMenu.Process(); }