The document describes object-oriented programming concepts like classes, objects, encapsulation, and properties. It provides code examples of a Time class that encapsulates time data and provides methods to work with it. The Time class uses properties to safely access private member variables for hour, minute and second. Constructors are demonstrated that initialize Time objects with different parameters.
The document discusses graphics and media capabilities in .NET, including graphics contexts, colors, fonts, and images. It covers creating graphics objects, setting colors using RGB values or names, constructing fonts and accessing font metrics, and loading/displaying images. Code examples are provided to demonstrate these graphics and font capabilities.
The document discusses object-oriented programming concepts like inheritance, base classes, and derived classes. It provides code examples to illustrate inheritance relationships between classes like Point, Circle, and Cylinder. The code defines base classes like Point and derived classes like Circle that inherit properties and methods from their base classes. Tests are provided to create objects from derived classes and demonstrate inherited functionality.
The document outlines control structures in programming, including counter-controlled repetition, the for loop structure, the switch multiple-selection structure, and the do/while repetition structure. It provides code examples to demonstrate these structures, including initializing and incrementing counters, using break and continue statements to alter loop flow, and displaying output.
The document discusses object-oriented programming concepts like polymorphism. It includes:
- An introduction to polymorphism and how it allows programs to handle related classes generically and be easily extensible.
- Examples of polymorphism including a shape hierarchy with classes like Quadrilateral, Rectangle, etc. and a space object hierarchy with classes that all implement a DrawYourself method.
- Details about abstract classes and how they provide base classes that concrete classes inherit from while requiring the concrete classes to implement abstract methods and properties.
- A case study demonstrating inheritance and polymorphism using abstract base class Shape and concrete classes Point2, Circle2, and Cylinder2 that inherit from Shape.
The document outlines a chapter on methods in C#. It discusses key concepts like defining methods, passing arguments by value vs reference, and using built-in classes like Math. It provides examples of methods that square integers, find the maximum of 3 numbers, and demonstrate passing by reference and out parameters.
The document discusses object-oriented programming concepts like polymorphism. It includes:
- An introduction to polymorphism and how it allows programs to handle related classes generically and be easily extensible.
- Examples of polymorphism including a shape hierarchy with classes like Square and Circle overriding a perimeter method, and a space object hierarchy with classes overriding a DrawYourself method.
- Details about abstract classes and how they provide base classes that concrete classes inherit from, including an example abstract Shape class and derived Point2, Circle2 classes.
The document discusses various graphical user interface controls in C#, including menus, link labels, list boxes, combo boxes, tree views, and tab controls. It provides code examples to demonstrate how to implement menus with options to change font colors and styles, as well as link labels that link to other programs or files when clicked. Event handlers are used to handle user interactions with the controls.
The document outlines the key topics covered in Chapter 15 on strings and characters in C#, including fundamentals of characters and strings, string constructors, using the string indexer and length property, comparing strings, and using methods like StartsWith and EndsWith. Code examples are provided to demonstrate using features like the string indexer, Length property, CopyTo method, comparing strings with Equals and CompareTo, and checking if a string starts or ends with a substring.
The document discusses graphics and media capabilities in .NET, including graphics contexts, colors, fonts, and images. It covers creating graphics objects, setting colors using RGB values or names, constructing fonts and accessing font metrics, and loading/displaying images. Code examples are provided to demonstrate these graphics and font capabilities.
The document discusses object-oriented programming concepts like inheritance, base classes, and derived classes. It provides code examples to illustrate inheritance relationships between classes like Point, Circle, and Cylinder. The code defines base classes like Point and derived classes like Circle that inherit properties and methods from their base classes. Tests are provided to create objects from derived classes and demonstrate inherited functionality.
The document outlines control structures in programming, including counter-controlled repetition, the for loop structure, the switch multiple-selection structure, and the do/while repetition structure. It provides code examples to demonstrate these structures, including initializing and incrementing counters, using break and continue statements to alter loop flow, and displaying output.
The document discusses object-oriented programming concepts like polymorphism. It includes:
- An introduction to polymorphism and how it allows programs to handle related classes generically and be easily extensible.
- Examples of polymorphism including a shape hierarchy with classes like Quadrilateral, Rectangle, etc. and a space object hierarchy with classes that all implement a DrawYourself method.
- Details about abstract classes and how they provide base classes that concrete classes inherit from while requiring the concrete classes to implement abstract methods and properties.
- A case study demonstrating inheritance and polymorphism using abstract base class Shape and concrete classes Point2, Circle2, and Cylinder2 that inherit from Shape.
The document outlines a chapter on methods in C#. It discusses key concepts like defining methods, passing arguments by value vs reference, and using built-in classes like Math. It provides examples of methods that square integers, find the maximum of 3 numbers, and demonstrate passing by reference and out parameters.
The document discusses object-oriented programming concepts like polymorphism. It includes:
- An introduction to polymorphism and how it allows programs to handle related classes generically and be easily extensible.
- Examples of polymorphism including a shape hierarchy with classes like Square and Circle overriding a perimeter method, and a space object hierarchy with classes overriding a DrawYourself method.
- Details about abstract classes and how they provide base classes that concrete classes inherit from, including an example abstract Shape class and derived Point2, Circle2 classes.
The document discusses various graphical user interface controls in C#, including menus, link labels, list boxes, combo boxes, tree views, and tab controls. It provides code examples to demonstrate how to implement menus with options to change font colors and styles, as well as link labels that link to other programs or files when clicked. Event handlers are used to handle user interactions with the controls.
The document outlines the key topics covered in Chapter 15 on strings and characters in C#, including fundamentals of characters and strings, string constructors, using the string indexer and length property, comparing strings, and using methods like StartsWith and EndsWith. Code examples are provided to demonstrate using features like the string indexer, Length property, CopyTo method, comparing strings with Equals and CompareTo, and checking if a string starts or ends with a substring.
The document outlines key concepts about arrays including:
- Declaring and allocating arrays
- Initializing arrays with initializer lists or dynamically with 'new'
- Accessing array elements using indexes/subscripts
- Common array operations like totaling elements, creating histograms, and using arrays as counters
It provides code examples demonstrating initializing arrays, summing array elements, creating a histogram to display array data, and using arrays as counters in a dice rolling simulation program.
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
This document discusses exception handling in .NET. It defines exceptions as objects that are thrown when errors or unexpected events occur during program execution. Exceptions allow errors to be handled at multiple levels through try-catch blocks. The core exception class is System.Exception, which other custom exceptions inherit from. Exceptions can be thrown manually with throw or occur automatically from errors. Finally blocks ensure code is always executed even if an exception is thrown.
The document contains 27 C# programs demonstrating various concepts in C# programming such as: getting user input and performing calculations; defining methods within classes; using instance variables; static variables and methods; inheritance; namespaces; constructors; destructors; method overloading and overriding; and the 'this' keyword. The programs cover basic to more advanced C# programming concepts.
Refactoring - improving the smell of your codevmandrychenko
The document discusses refactoring code to improve its quality without changing its external behavior. It defines refactoring and explains why it is important to make code easier to understand and maintain over time. It provides examples of "code smells" that indicate needs for refactoring and discusses techniques for refactoring code, such as renaming methods, extracting interfaces, replacing conditionals with polymorphism, and using tools to help with the process.
The document describes implementing a Windows Forms application in C# using various controls like menus, dialog boxes, and tooltips. It includes code for handling events like loading the form, clicking menu items like File and Edit, and clicking items on a toolbar. The application demonstrates using common controls and handling events in a Windows Forms application.
The document contains 8 C# programs that print various patterns. The programs use for loops and if/else statements to iterate through arrays or integers and print numbers or values in a specific patterned format. They demonstrate ways to print triangles, grids, ascending/descending sequences and more using basic programming constructs.
The program defines a jagged array with 3 inner arrays of unspecified length. It initializes the inner arrays. It then iterates through the jagged array and sums all elements of the inner arrays. The total sum is returned.
1. The document discusses elementary programming concepts in Java such as variables, data types, operators, and expressions. It provides examples of computing the area of a circle and converting temperatures between Fahrenheit and Celsius.
2. Tracing the execution of a sample area computation program is demonstrated. Key steps include declaring variables, assigning values, performing calculations, and printing output.
3. Numeric data types in Java are explained along with various arithmetic operators for performing calculations on integer and floating-point values.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
The document discusses various concepts related to abstraction in software development including project architecture, code refactoring, enumerations, and the static keyword in Java. It describes how to split code into logical parts using methods and classes to improve readability, reuse code, and avoid repetition. Refactoring techniques like extracting methods and classes are presented to restructure code without changing behavior. Enumerations are covered as a way to represent numeric values from a fixed set as text. The static keyword is explained for use with classes, variables, methods, and blocks to belong to the class rather than object instances.
Modes of Operation and its applications
Multiple Encryption and Meet-in-the Middle Attack
SHA-1 and SHA-3
HMAC and CBC-MAC and its Security
CBC-MAC implementation
The document provides information about creating graphical user interface (GUI) applications in Java using Swing. It discusses creating JFrames to contain other Swing components, using classes like JLabel to add text, and handling events when the user closes the frame. It also covers drawing shapes directly by overriding the paintComponent method in a JComponent subclass and using Graphics2D to draw rectangles, lines, ellipses, and other shapes. The document demonstrates how to get user input by displaying JOptionPanes and shows an example application that draws a colored square based on RGB values entered by the user.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
The document outlines a Java programming practical course covering various Java concepts and programs. It includes 40 practical programs to be completed ranging from basic programs to find area of a circle, factorial of a number to more advanced programs involving OOP concepts like inheritance, abstraction, exception handling and multithreading. It also provides the evaluation and marking scheme for the practical exam.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this chapter we will get more familiar with what methods are and why we need to use them. The reader will be shown how to declare methods, what parameters are and what a method’s signature is, how to call a method, how to pass arguments of methods and how methods return values. At the end of this chapter we will know how to create our own method and how to use (invoke) it whenever necessary. Eventually, we will suggest some good practices in working with methods. The content of this chapter accompanied by detailed examples and exercises that will help the reader practice the learned material.
The document describes 10 C# programming examples covering various concepts:
1. The first example demonstrates branching and looping using a for loop and if/else statements.
2. The second example uses arrays, strings, and methods by getting user input into an array and displaying it.
3. The third example demonstrates structures and enumerations by creating a structure and enum.
4. Further examples cover inheritance, polymorphism, interfaces, operator overloading, exceptions, building a calculator application, and multi-module assemblies.
This document contains instructions and questions for a computer science exam. It covers topics like call by value vs call by reference in C++, header files, class definitions, functions, arrays, pointers, structures, inheritance, and file input/output. There are multiple choice, short answer, and code writing questions testing a variety of programming concepts.
The document discusses selection statements and conditional logic in Java. It covers if, if-else, and nested if statements. It provides truth tables for common logical operators like &&, ||, !, and ^. It also presents several examples of programs that use conditional logic to check conditions and produce different outputs based on the results, such as computing BMI, generating math quizzes, and calculating lottery winnings.
This document discusses object-oriented programming concepts like classes, objects, encapsulation, and constructors. It provides an example of implementing a Time class with different constructors. The Time class encapsulates hour, minute and second variables and provides methods to set the time, and output it in universal and standard time formats. The document shows how to instantiate Time objects using various constructors, and how overloaded constructors allow initializing objects in different ways.
Classes and Objects introduces object-oriented programming concepts like encapsulation, classes, and objects. A class defines the data attributes and behaviors of an object using data members and member functions. Objects are instantiated from classes and can access members using dot or arrow operators. The implementation of classes separates the interface from the implementation allowing for easier modification. Access specifiers like public and private control access to members. Utility functions support public functions without exposing implementation details.
The document outlines key concepts about arrays including:
- Declaring and allocating arrays
- Initializing arrays with initializer lists or dynamically with 'new'
- Accessing array elements using indexes/subscripts
- Common array operations like totaling elements, creating histograms, and using arrays as counters
It provides code examples demonstrating initializing arrays, summing array elements, creating a histogram to display array data, and using arrays as counters in a dice rolling simulation program.
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
This document discusses exception handling in .NET. It defines exceptions as objects that are thrown when errors or unexpected events occur during program execution. Exceptions allow errors to be handled at multiple levels through try-catch blocks. The core exception class is System.Exception, which other custom exceptions inherit from. Exceptions can be thrown manually with throw or occur automatically from errors. Finally blocks ensure code is always executed even if an exception is thrown.
The document contains 27 C# programs demonstrating various concepts in C# programming such as: getting user input and performing calculations; defining methods within classes; using instance variables; static variables and methods; inheritance; namespaces; constructors; destructors; method overloading and overriding; and the 'this' keyword. The programs cover basic to more advanced C# programming concepts.
Refactoring - improving the smell of your codevmandrychenko
The document discusses refactoring code to improve its quality without changing its external behavior. It defines refactoring and explains why it is important to make code easier to understand and maintain over time. It provides examples of "code smells" that indicate needs for refactoring and discusses techniques for refactoring code, such as renaming methods, extracting interfaces, replacing conditionals with polymorphism, and using tools to help with the process.
The document describes implementing a Windows Forms application in C# using various controls like menus, dialog boxes, and tooltips. It includes code for handling events like loading the form, clicking menu items like File and Edit, and clicking items on a toolbar. The application demonstrates using common controls and handling events in a Windows Forms application.
The document contains 8 C# programs that print various patterns. The programs use for loops and if/else statements to iterate through arrays or integers and print numbers or values in a specific patterned format. They demonstrate ways to print triangles, grids, ascending/descending sequences and more using basic programming constructs.
The program defines a jagged array with 3 inner arrays of unspecified length. It initializes the inner arrays. It then iterates through the jagged array and sums all elements of the inner arrays. The total sum is returned.
1. The document discusses elementary programming concepts in Java such as variables, data types, operators, and expressions. It provides examples of computing the area of a circle and converting temperatures between Fahrenheit and Celsius.
2. Tracing the execution of a sample area computation program is demonstrated. Key steps include declaring variables, assigning values, performing calculations, and printing output.
3. Numeric data types in Java are explained along with various arithmetic operators for performing calculations on integer and floating-point values.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
The document discusses various concepts related to abstraction in software development including project architecture, code refactoring, enumerations, and the static keyword in Java. It describes how to split code into logical parts using methods and classes to improve readability, reuse code, and avoid repetition. Refactoring techniques like extracting methods and classes are presented to restructure code without changing behavior. Enumerations are covered as a way to represent numeric values from a fixed set as text. The static keyword is explained for use with classes, variables, methods, and blocks to belong to the class rather than object instances.
Modes of Operation and its applications
Multiple Encryption and Meet-in-the Middle Attack
SHA-1 and SHA-3
HMAC and CBC-MAC and its Security
CBC-MAC implementation
The document provides information about creating graphical user interface (GUI) applications in Java using Swing. It discusses creating JFrames to contain other Swing components, using classes like JLabel to add text, and handling events when the user closes the frame. It also covers drawing shapes directly by overriding the paintComponent method in a JComponent subclass and using Graphics2D to draw rectangles, lines, ellipses, and other shapes. The document demonstrates how to get user input by displaying JOptionPanes and shows an example application that draws a colored square based on RGB values entered by the user.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
The document outlines a Java programming practical course covering various Java concepts and programs. It includes 40 practical programs to be completed ranging from basic programs to find area of a circle, factorial of a number to more advanced programs involving OOP concepts like inheritance, abstraction, exception handling and multithreading. It also provides the evaluation and marking scheme for the practical exam.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this chapter we will get more familiar with what methods are and why we need to use them. The reader will be shown how to declare methods, what parameters are and what a method’s signature is, how to call a method, how to pass arguments of methods and how methods return values. At the end of this chapter we will know how to create our own method and how to use (invoke) it whenever necessary. Eventually, we will suggest some good practices in working with methods. The content of this chapter accompanied by detailed examples and exercises that will help the reader practice the learned material.
The document describes 10 C# programming examples covering various concepts:
1. The first example demonstrates branching and looping using a for loop and if/else statements.
2. The second example uses arrays, strings, and methods by getting user input into an array and displaying it.
3. The third example demonstrates structures and enumerations by creating a structure and enum.
4. Further examples cover inheritance, polymorphism, interfaces, operator overloading, exceptions, building a calculator application, and multi-module assemblies.
This document contains instructions and questions for a computer science exam. It covers topics like call by value vs call by reference in C++, header files, class definitions, functions, arrays, pointers, structures, inheritance, and file input/output. There are multiple choice, short answer, and code writing questions testing a variety of programming concepts.
The document discusses selection statements and conditional logic in Java. It covers if, if-else, and nested if statements. It provides truth tables for common logical operators like &&, ||, !, and ^. It also presents several examples of programs that use conditional logic to check conditions and produce different outputs based on the results, such as computing BMI, generating math quizzes, and calculating lottery winnings.
This document discusses object-oriented programming concepts like classes, objects, encapsulation, and constructors. It provides an example of implementing a Time class with different constructors. The Time class encapsulates hour, minute and second variables and provides methods to set the time, and output it in universal and standard time formats. The document shows how to instantiate Time objects using various constructors, and how overloaded constructors allow initializing objects in different ways.
Classes and Objects introduces object-oriented programming concepts like encapsulation, classes, and objects. A class defines the data attributes and behaviors of an object using data members and member functions. Objects are instantiated from classes and can access members using dot or arrow operators. The implementation of classes separates the interface from the implementation allowing for easier modification. Access specifiers like public and private control access to members. Utility functions support public functions without exposing implementation details.
lecture10.ppt fir class ibect fir c++ fr oppsmanomkpsg
Classes and Objects introduces object-oriented programming concepts like encapsulation, classes, and objects. A class defines the data attributes and behaviors of an object. Objects are instantiated from classes. The document then discusses using structures to define custom data types before introducing classes as a better way to implement abstract data types using encapsulation. It provides examples of defining Time classes to represent time values and operations on them. Member functions are defined both inside and outside classes using the scope resolution operator. Access specifiers control access to class members.
Classes and Objects introduce object-oriented programming concepts like encapsulation and classes. A class defines the data attributes and behaviors of an object. Objects are instantiated from classes and resemble real-world objects. The document discusses class structure definitions, accessing structure members, implementing a time abstract data type with a class, and separating interface from implementation with header files.
This document summarizes Chapter 17 of a C++ textbook, which covers advanced class concepts in C++. The chapter discusses:
1. Constant objects and constant member functions that cannot modify objects.
2. Composition, where classes can contain objects of other classes as members. Member objects are constructed before the enclosing object.
3. Friend functions and classes that have access to private and protected members of other classes.
4. Using the 'this' pointer to access members from within member functions.
5. Dynamic memory allocation using operators new and delete.
6. Static class members that are shared among all class objects.
7. Data abstraction and information hiding techniques using classes.
1. The document discusses separating a class interface from its implementation by defining the class in a header file and defining member functions in a source code file.
2. It shows a Time class defined in the time1.h header file and member functions defined in the time1.cpp source file.
3. A driver program includes the header file, creates a Time object, and calls member functions to demonstrate the separation of interface and implementation.
1. The document discusses separating a class interface from its implementation by defining the class in a header file and defining member functions in a source code file.
2. It shows a Time class defined in the time1.h header file and its member functions defined in the time1.cpp source file.
3. A driver program includes the header file, creates a Time object, and calls member functions to demonstrate separating interface and implementation works as expected.
The document discusses different ways to represent date and time in Java. It introduces the new Date Time API introduced in Java 8, which includes classes like LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Clock, Instant, Duration, Period, ZoneId, ZoneOffset, and DateTimeFormatter. The document then provides examples of common date and time tasks like getting the current date and time, parsing and formatting dates, measuring elapsed time between two points, and calculating days between two dates.
JAVA.Q4 Create a Time class. This class will represent a point in.pdfkarymadelaneyrenne19
JAVA.
Q4: Create a Time class. This class will represent a point in time, such as a departure time. It
should contain 2 constructors, 2 instance variables (hour and minute), and 10 methods (see
below). All methods but toString should be in terms of the 24 hour format. [30 points]
default constructor: Creates a Time object for 12:00AM.
overloaded constructor: Creates a Time object at a specific hour and minute.
getHour(): Returns an integer representing the hour of the Time object.
getMinute(): Returns an integer representing the minute of the Time object.
addHours(...): Updates the object by moving it forward a number of hours.
addMinute(...): Updates the object by moving it forward a number of minutes. (Hint: Be careful
that you don\'t allow minutes to be more than 59.)
addTime(...): Updates the object by moving it forward by the hour and minute from another
Time object.
getCopy(...): Returns a new Time object that has the same hour and minute of the existing Time
object.
isEarlierThan(...): Returns true if this Time object is earlier than another Time object.
isSameTime(...): Returns true if this Time object is the same as another Time object.
isLaterThan(...): Returns true if this Time object is later than another Time object.
toString(): Returns a string representing the Time object. Uses 12 hour AM/PM format and pads
minutes to be two digits. See the sample output for an example.
Q5: Create a Flight class that uses the Plane and Time class. This class will represent a flight
between two airports, using a specific Plane, and departing at a specific Time. It should contain a
constructor, 7 instance variables (plane, flight number, cost, departure, duration, source,
destination), and 9 methods (see below). [25 points]
overloaded constructor: Creates a Flight object that is setup up with a Plane, a flight number, a
cost, a departure Time, a duration time, a source Airport, and a destination Airport.
getPlane(): Returns the Plane that operates this flight.
getNumber(): Returns the flight number.
getCost(): Returns the flight cost.
getDestination(): Returns the destination Airport.
getDeparture(): Returns the departure Time.
getArrival(): Returns a Time object with the arrival time (computed from the departure time and
duration).
getSource(): Returns a Airport object for the departure location.
toOverviewString(): Returns a String representing an overview of the flight. Use NumberFormat
to display the price. See the sample output for an example.
toDetailedString(): Returns a String representing the flight\'s detail information. See the sample
output for an example.
Included below is an overall UML diagram that describes the three classes you will be
constructing. It provides a useful summary of all of the methods you are expected to implement,
and their corresponding types and visibility. Notice that one private method is listed here
(formatDigits in Time) that isn\'t mentioned above. This is a method that was in our solution, you
may not need.
The document provides an overview of key concepts in the C# programming language including variables and data types, arrays, conditional logic, loops, methods, parameters, and delegates. It discusses basic syntax, operators, and how to perform common tasks like type conversions and working with dates and strings. The goal is to give readers enough information to get started with C# as well as refer back to for language details while working through ASP.NET examples.
The document provides an overview of classes and objects in Java. It discusses container classes versus definition classes, and gives examples of the Math and Turtle classes. It explains key concepts like abstraction, encapsulation, and the relationship between classes and objects. Specific examples like the Clock and BankAccount classes are used to illustrate concepts like instance variables, constructors, methods, visibility modifiers, and API documentation.
Military time and Standard time, JavaOne of the assignments given .pdfmarketing413921
The document provides guidelines for creating a program to work with military time and standard time. It specifies to create four Java classes - Time, MilTime, TimeClock, and a main class. The Time class defines the basic time properties. MilTime extends Time and adds military time functionality. TimeClock extends MilTime and adds start and end time properties to calculate time differences. The main class is meant to test the other classes by getting user input for military time values and displaying outputs.
Modify the Time classattached to be able to work with Date.pdfaaseletronics2013
Modify the Time class(attached) to be able to work with Date class. The Time object should
always remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member
function that increments the time stored in a Date object by one second, and increaseADay
function to increase day, month and year when it is proper. Please use CISP400V10A4.cpp that
tests the tick member function in a loop that prints the time in standard format during iteration of
the loop to illustrate that the tick member function works correctly. Be aware that we are testing
the following cases:
a) Incrementing into the next minute.
b) Incrementing into the next hour.
c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
d) Incrementing into the next month and next year.
You can adjust only programs (Date.cpp, Date.h, Time.cpp and Time.h) to generate the
required result but not the code in CISP400V10A4.cpp file.
Expecting results:
// Date.cpp
// Date class member-function definitions.
#include <array>
#include <string>
#include <iostream>
#include <stdexcept>
#include "Date.h" // include Date class definition
using namespace std;
// constructor confirms proper value for month; calls
// utility function checkDay to confirm proper value for day
Date::Date(int mn, int dy, int yr, Time time)
: time01(time)
{
if (mn > 0 && mn <= monthsPerYear) // validate the month
month = mn;
else
throw invalid_argument("month must be 1-12");
year = yr; // could validate yr
day = checkDay(dy); // validate the day
// output Date object to show when its constructor is called
cout << "Date object constructor for date ";
print();
cout << endl;
} // end Date constructor
// print Date object in form month/day/year
void Date::print() const
{
cout << month << '/' << day << '/' << year;
cout << "t";
time01.printStandard();
cout << "t";
time01.printUniversal();
cout << "n";
} // end function print
// output Date object to show when its destructor is called
Date::~Date()
{
cout << "Date object destructor for date ";
print();
cout << endl;
} // end ~Date destructor
// utility function to confirm proper day value based on
// month and year; handles leap years, too
unsigned int Date::checkDay(int testDay) const
{
static const array< int, monthsPerYear + 1 > daysPerMonth =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// determine whether testDay is valid for specified month
if (testDay > 0 && testDay <= daysPerMonth[month])
{
return testDay;
} // end if
// February 29 check for leap year
if (month == 2 && testDay == 29 && (year % 400 == 0 || (year % 4 == 0 && year
% 100 != 0)))
{
return testDay;
} // end if
cout << "day (" << testDay << ") set to 1." << endl;
return 1;
} // end function checkDay
// adjust data if day is not proper
void Date::increaseADay()
{
day = checkDay(day + 1);
if (day == 1) // if day wasn't accurate, its value is one
{
month = month + 1; // increase month by 1
if (month > 0 && month >= monthsPerYear) // if.
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
C++
"Please I am posting the fifth time and hoping to get this resolved. I want the year to
change from 2014 to 2015 but the days of the month change to 32 rather than 1/1/2015.
Also, Please I want personal information in the heading as well Name: Last: and Course
Name:"
Modify the Time class(attached) to be able to work with Date class. The Time object should
always
remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member
function that increments the time stored in a Date object by one second, and increaseADay
function to
increase day, month and year when it is proper. Please use CISP400V10A4.cpp that tests the tick
member function in a loop that prints the time in standard format during iteration of the loop to
illustrate that the tick member function works correctly. Be aware that we are testing the following
cases:
a) Incrementing into the next minute.
b) Incrementing into the next hour.
c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
d) Incrementing into the next month and next year.
Time class
The Time class has three private integer data members, hour (0 - 23 (24-hour clock format)),
minute (0
59), and second (0 59).
It also has Time, setTime, setHour, setMinute, setSecond, getHour(), getMinute,
getSecond,~Time,
printUniversal, and printStandard public functions.
1. The Time function is a default constructor. It takes three integers and they all have 0 as default
values. It also displays "Time object constructor is called." message and calls
printStandard
and printUniversal functions.
2. The setTime function takes three integers but does not return any value. It initializes the
private data members (hour, minute and second) data.
3. The setHour function takes one integer but doesnt return anything. It validates and stores the
integer to the hour private data member.
4. The setMinute function takes one integer but doesnt return anything. It validates and stores
the integer to the minute private data member.
5. The setSecond function takes one integer but doesnt return anything. It validates and stores
the integer to the second private data member.
Page 3 of 11 CISP400V10A4
6. The getHour constant function returns one integer but doesnt take anything. It returns the
private data member hours data.
7. The getMinute constant function returns one integer but doesnt take anything. It returns the
private data member minutes data.
8. The getSecond constant function returns one integer but doesnt take anything. It returns the
private data member seconds data.
9. The Time destructor does not take anything. It displays "Time object destructor is
called."
message and calls printStandard and printUniversal functions.
10. The printUniversal constant function does not return or accept anything. It displays time in
universal-time format.
11. The printStandard constant function does not return or accept anything. It displays time in
standard-ti.
The document discusses parallel programming in .NET. It covers two main strategies for parallelism - data parallelism and task parallelism. For data parallelism, it describes using Parallel.For to partition work over collections. For task parallelism, it discusses using the Task Parallel Library to create and run independent tasks concurrently, allowing work to be distributed across multiple processors. It provides examples of creating tasks implicitly with Parallel.Invoke and explicitly by instantiating Task objects and passing delegates.
1) The document discusses user-defined classes in Java, including defining classes with modifiers, data declarations, and method definitions. It provides examples of class definitions with private instance variables and public methods.
2) It describes the syntax for defining methods, including the method header with return type and parameters. The document explains value-returning methods, void methods, and use of return statements.
3) The document shows an example class definition for a Rectangle with constructor, getter, and calculateArea methods to demonstrate object instantiation and method calls.
This document discusses Java methods and provides examples of method declarations and usage. Key points include:
- Methods allow programmers to modularize programs into reusable pieces of code.
- The general format for declaring a method includes specifying the return type, method name, and parameters.
- Methods can return values using the return statement.
- The Math class contains commonly used methods like sqrt() and max() for mathematical operations.
- Examples demonstrate declaring and calling methods to calculate squares of integers, find the maximum of three numbers, and generate random numbers.
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
The question asks to create classes to represent publications, books, and tapes. The Publication class has title and price attributes. The Book class inherits from Publication and adds a noOfPages attribute. The Tape class inherits from Publication and adds a playingTime attribute.
Please I am posting the fifth time and hoping to get this r.pdfankit11134
"Please I am posting the fifth time and hoping to get this resolved. I want the year to
change from 2014 to 2015 but the days of the month change to 32 rather than 1/1/2015.
Also, Please I want personal information in the heading as well Name: Last: and Course
Name:"
Modify the Time class(attached) to be able to work with Date class. The Time object should
always
remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member
function that increments the time stored in a Date object by one second, and increaseADay
function to
increase day, month and year when it is proper. Please use CISP400V10A4.cpp that tests the tick
member function in a loop that prints the time in standard format during iteration of the loop to
illustrate that the tick member function works correctly. Be aware that we are testing the following
cases:
a) Incrementing into the next minute.
b) Incrementing into the next hour.
c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
d) Incrementing into the next month and next year.
Time class
The Time class has three private integer data members, hour (0 - 23 (24-hour clock format)),
minute (0
59), and second (0 59).
It also has Time, setTime, setHour, setMinute, setSecond, getHour(), getMinute,
getSecond,~Time,
printUniversal, and printStandard public functions.
1. The Time function is a default constructor. It takes three integers and they all have 0 as default
values. It also displays "Time object constructor is called." message and calls
printStandard
and printUniversal functions.
2. The setTime function takes three integers but does not return any value. It initializes the
private data members (hour, minute and second) data.
3. The setHour function takes one integer but doesnt return anything. It validates and stores the
integer to the hour private data member.
4. The setMinute function takes one integer but doesnt return anything. It validates and stores
the integer to the minute private data member.
5. The setSecond function takes one integer but doesnt return anything. It validates and stores
the integer to the second private data member.
Page 3 of 11 CISP400V10A4
6. The getHour constant function returns one integer but doesnt take anything. It returns the
private data member hours data.
7. The getMinute constant function returns one integer but doesnt take anything. It returns the
private data member minutes data.
8. The getSecond constant function returns one integer but doesnt take anything. It returns the
private data member seconds data.
9. The Time destructor does not take anything. It displays "Time object destructor is
called."
message and calls printStandard and printUniversal functions.
10. The printUniversal constant function does not return or accept anything. It displays time in
universal-time format.
11. The printStandard constant function does not return or accept anything. It displays time in
standard-time f.
This document discusses concurrent programming and multithreaded programming in Java. It covers key topics such as creating and controlling threads, thread safety and synchronization, and using bounded queues to allow cooperation between producer and consumer threads.
This document outlines key concepts related to data structures including linked lists, stacks, queues, and trees. It provides code examples of a Node class that is self-referential, allowing objects to link to one another. A LinkedListLibrary class is defined, with methods for inserting and removing nodes from linked lists. A ListTest class tests the functionality of the List class.
The document discusses accessibility in web development and software applications. It covers regulations and guidelines for accessibility from the Web Accessibility Initiative (WAI) and other organizations. It also provides examples of implementing accessibility in Visual Studio .NET, C#, XHTML, and Microsoft Windows, including features for visual impairments, hearing impairments, and mobility issues. Specific techniques discussed include adding alt text for images, proper use of headings and structure, keyboard shortcuts, screen reading support, font size adjustments, and more.
The document discusses accessibility in web development and software applications. It covers topics like web accessibility guidelines, providing alternatives for images, maximizing readability in structures, accessibility in Visual Studio .NET, C#, XHTML tables and frames, and accessibility tools. Code examples are provided to demonstrate making applications more accessible for people with disabilities.
The document discusses client-server networking using both stream sockets and datagrams. It provides code examples for a server and client application that allow text-based communication using stream sockets, establishing a connection between the two. It also gives an example of a connectionless server and client that can send and receive datagrams containing byte arrays to simulate a chat. The server waits for packets and displays the contents, then echoes the data back to the client.
This document outlines a chapter about ASP.NET and web services. It includes code for a web service called HugeInteger that performs operations on large integers. The HugeInteger service exposes methods like Add, Subtract, Bigger etc through SOAP over HTTP. It shows how to publish web services, add service references to projects, and invoke web service methods from a client application.
This chapter discusses ASP.NET web forms and controls. It introduces the system architecture of web applications with different tiers. It then demonstrates creating a simple web form application in Visual Studio that displays the current time using labels and setting properties in the code-behind file. The application is run locally and the generated HTML is shown.
The document outlines how to connect to and query an Access database using ADO.NET in C#. It describes creating a TableDisplay form with a DataGrid to display query results. The form initializes a DataSet and OleDbDataAdapter to retrieve data from the Authors table and bind it to the DataGrid. It also configures OleDbCommands for selecting, inserting, updating, and deleting data.
This document discusses XML and the Document Object Model (DOM). It introduces XML documents and namespaces. It describes how the DOM represents an XML document as a tree structure with parent and child nodes. It provides code examples for reading an XML file using an XmlReader, and manipulating an XML document's DOM tree by building a copy of the tree as TreeNodes in a TreeView control.
The document describes how to search directories and files using the File and Directory classes in C#. It defines a regular expression to match file extensions and stores the number of files found for each extension. The program recursively searches all subdirectories, counts the number of files for each extension, and outputs a summary of the results. It also checks for and allows deleting any backup (.bak) files found.
The document describes multithreading concepts in .NET including thread states, priorities, synchronization, and the producer-consumer relationship. It provides code examples to demonstrate threading without and with synchronization. Key points covered include allowing concurrent execution with threads, thread life cycles and states, using monitors for synchronization, and ensuring proper communication between producer and consumer threads.
This document provides an outline and overview of Chapter 12 which covers graphical user interface (GUI) concepts in Windows Forms. The chapter introduces GUI components like windows, controls, properties, events and event handling. It describes common controls like labels, text boxes, buttons and how to set properties, handle events, and lay out controls on a form. Code examples are provided to demonstrate creating a simple form with a textbox, label and button to display text on a label when a button is clicked.
This document discusses exception handling in C# and .NET. It provides examples of try/catch blocks, the different exception classes in .NET, and how to access exception properties like Message and StackTrace. Code samples are given that demonstrate throwing, catching, and rethrowing exceptions. Finally blocks are also discussed and shown to always execute even if an exception occurs.
The document outlines control structures in programming including algorithms, pseudocode, selection structures like if/else, repetition structures like while loops, and case studies applying these concepts. Key topics are counter-controlled and sentinel-controlled repetition for loops, and nesting control structures with if statements inside loops. Examples in C# demonstrate accumulating values in loops and nested if/else statements.
This document outlines the key concepts covered in Chapter 3 of an introduction to C# programming textbook. It discusses simple programs that print text, perform basic math operations, and make decisions using relational operators. Code examples are provided to demonstrate how to write, compile, and run simple C# console applications and use basic programming elements like variables, methods, and conditional statements.
The document provides an overview of the Visual Studio .NET integrated development environment (IDE). It describes the main interface elements like the menu bar, toolbar, solution explorer, toolbox and properties window. It then demonstrates how to create a simple project in Visual Studio .NET that displays text in a label and an image in a picture box without writing any code, using the drag and drop features of the IDE.
The document provides an overview of computers, operating systems, programming languages, the internet, and Microsoft .NET. It discusses the evolution of computers from early mainframes to personal computers and networks. It covers the development of operating systems, languages like C, C++, Java and C#, and web technologies like HTML, XML and the World Wide Web. It also summarizes Microsoft's .NET framework and how it allows applications to be developed in any .NET compatible language and run across platforms using the Common Language Runtime.
The document outlines key concepts about data structures including linked lists, stacks, queues, and trees. It provides code examples for a Node class that is self-referential, allowing objects to link to each other. It also includes a List class that implements basic linked list functionality through methods like InsertAtFront, InsertAtBack, RemoveFromFront, and RemoveFromBack. The code examples demonstrate how to create and manipulate linked lists through a List object.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
20 Comprehensive Checklist of Designing and Developing a WebsitePixlogix Infotech
Dive into the world of Website Designing and Developing with Pixlogix! Looking to create a stunning online presence? Look no further! Our comprehensive checklist covers everything you need to know to craft a website that stands out. From user-friendly design to seamless functionality, we've got you covered. Don't miss out on this invaluable resource! Check out our checklist now at Pixlogix and start your journey towards a captivating online presence today.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
1. Chapter 8 – Object-Based Programming Outline 8.1 Introduction 8.2 Implementing a Time Abstract Data Type with a Class 8.3 Class Scope 8.4 Controlling Access to Members 8.5 Initializing Class Objects: Constructors 8.6 Using Overloaded Constructors 8.7 Properties 8.8 Composition: Objects as Instance Variables of Other Classes 8.9 Using the this Reference 8.10 Garbage Collection 8.11 static Class Members 8.12 const and readonly Members 8.13 Indexers 8.14 Data Abstraction and Information Hiding 8.15 Software Reusability 8.16 Namespaces and Assemblies 8.17 Class View and Object Browser
2.
3.
4.
5. Time1.cs 1 // Fig. 8.1: Time1.cs 2 // Class Time1 maintains time in 24-hour format. 3 4 using System; 5 6 // Time1 class definition 7 public class Time1 : Object 8 { 9 private int hour; // 0-23 10 private int minute; // 0-59 11 private int second; // 0-59 12 13 // Time1 constructor initializes instance variables to 14 // zero to set default time to midnight 15 public Time1() 16 { 17 SetTime( 0 , 0 , 0 ); 18 } 19 20 // Set new time value in 24-hour format. Perform validity 21 // checks on the data. Set invalid values to zero. 22 public void SetTime( 23 int hourValue, int minuteValue, int secondValue ) 24 { 25 hour = ( hourValue >= 0 && hourValue < 24 ) ? 26 hourValue : 0 ; 27 minute = ( minuteValue >= 0 && minuteValue < 60 ) ? 28 minuteValue : 0 ; 29 second = ( secondValue >= 0 && secondValue < 60 ) ? 30 secondValue : 0 ; 31 } 32 Private instance variables Default constructor Method SetTime Validate arguments
6. Time1.cs 33 // convert time to universal-time (24 hour) format string 34 public string ToUniversalString() 35 { 36 return String.Format( 37 "{0:D2}:{1:D2}:{2:D2}" , hour, minute, second ); 38 } 39 40 // convert time to standard-time (12 hour) format string 41 public string ToStandardString() 42 { 43 return String.Format( "{0}:{1:D2}:{2:D2} {3}" , 44 ( ( hour == 12 || hour == 0 ) ? 12 : hour % 12 ), 45 minute, second, ( hour < 12 ? "AM" : "PM" ) ); 46 } 47 48 } // end class Time1 Output time in universal format Output time in standard format
7. TimeTest1.cs 1 // Fig. 8.2: TimeTest1.cs 2 // Demonstrating class Time1. 3 4 using System; 5 using System.Windows.Forms; 6 7 // TimeTest1 uses creates and uses a Time1 object 8 class TimeTest1 9 { 10 // main entry point for application 11 static void Main( string [] args ) 12 { 13 Time1 time = new Time1(); // calls Time1 constructor 14 string output; 15 16 // assign string representation of time to output 17 output = "Initial universal time is: " + 18 time.ToUniversalString() + 19 "Initial standard time is: " + 20 time.ToStandardString(); 21 22 // attempt valid time settings 23 time.SetTime( 13 , 27 , 6 ); 24 25 // append new string representations of time to output 26 output += "Universal time after SetTime is: " + 27 time.ToUniversalString() + 28 "Standard time after SetTime is: " + 29 time.ToStandardString(); 30 31 // attempt invalid time settings 32 time.SetTime( 99 , 99 , 99 ); 33 Call default time constructor Call method SetTime to set the time with valid arguments Call method SetTime with invalid arguments
8. TimeTest1.cs Program Output 34 output += "After attempting invalid settings: " + 35 "Universal time: " + time.ToUniversalString() + 36 "Standard time: " + time.ToStandardString(); 37 38 MessageBox.Show( output, "Testing Class Time1" ); 39 40 } // end method Main 41 42 } // end class TimeTest1
9.
10.
11. RestrictedAccess.cs Program Output 1 // Fig. 8.3: RestrictedAccess.cs 2 // Demonstrate compiler errors from attempt to access 3 // private class members. 4 5 class RestrictedAccess 6 { 7 // main entry point for application 8 static void Main( string [] args ) 9 { 10 Time1 time = new Time1(); 11 12 time.hour = 7; 13 time.minute = 15; 14 time.second = 30; 15 } 16 17 } // end class RestrictedAccess Attempt to access private members
12.
13. Time2.cs 1 // Fig. 8.4: Time2.cs 2 // Class Time2 provides overloaded constructors. 3 4 using System; 5 6 // Time2 class definition 7 public class Time2 8 { 9 private int hour; // 0-23 10 private int minute; // 0-59 11 private int second; // 0-59 12 13 // Time2 constructor initializes instance variables to 14 // zero to set default time to midnight 15 public Time2() 16 { 17 SetTime( 0 , 0 , 0 ); 18 } 19 20 // Time2 constructor: hour supplied, minute and second 21 // defaulted to 0 22 public Time2( int hour ) 23 { 24 SetTime( hour, 0 , 0 ); 25 } 26 27 // Time2 constructor: hour and minute supplied, second 28 // defaulted to 0 29 public Time2( int hour, int minute ) 30 { 31 SetTime( hour, minute, 0 ); 32 } 33 Default constructor Constructor which takes the hour as the input Constructor which takes the hour and minute as input
18. Time3.cs 1 // Fig. 8.6: Time3.cs 2 // Class Time2 provides overloaded constructors. 3 4 using System; 5 6 // Time3 class definition 7 public class Time3 8 { 9 private int hour; // 0-23 10 private int minute; // 0-59 11 private int second; // 0-59 12 13 // Time3 constructor initializes instance variables to 14 // zero to set default time to midnight 15 public Time3() 16 { 17 SetTime( 0 , 0 , 0 ); 18 } 19 20 // Time3 constructor: hour supplied, minute and second 21 // defaulted to 0 22 public Time3( int hour ) 23 { 24 SetTime( hour, 0 , 0 ); 25 } 26 27 // Time3 constructor: hour and minute supplied, second 28 // defaulted to 0 29 public Time3( int hour, int minute ) 30 { 31 SetTime( hour, minute, 0 ); 32 } 33
19. Time3.cs 34 // Time3 constructor: hour, minute and second supplied 35 public Time3( int hour, int minute, int second ) 36 { 37 SetTime( hour, minute, second ); 38 } 39 40 // Time3 constructor: initialize using another Time3 object 41 public Time3( Time3 time ) 42 { 43 SetTime( time.Hour, time.Minute, time.Second ); 44 } 45 46 // Set new time value in 24-hour format. Perform validity 47 // checks on the data. Set invalid values to zero. 48 public void SetTime( 49 int hourValue, int minuteValue, int secondValue ) 50 { 51 Hour = hourValue; 52 Minute = minuteValue; 53 Second = secondValue; 54 } 55 56 // property Hour 57 public int Hour 58 { 59 get 60 { 61 return hour; 62 } 63 64 set 65 { 66 hour = ( ( value >= 0 && value < 24 ) ? value : 0 ); 67 } 68 Constructor that takes another Time3 object as an argument. New Time3 object is initialized with the values of the argument. Property Hour
20. Time3.cs 69 } // end property Hour 70 71 // property Minute 72 public int Minute 73 { 74 get 75 { 76 return minute; 77 } 78 79 set 80 { 81 minute = ( ( value >= 0 && value < 60 ) ? value : 0 ); 82 } 83 84 } // end property Minute 85 86 // property Second 87 public int Second 88 { 89 get 90 { 91 return second; 92 } 93 94 set 95 { 96 second = ( ( value >= 0 && value < 60 ) ? value : 0 ); 97 } 98 99 } // end property Second 100 Property Minute Property Second
21. Time3.cs 101 // convert time to universal-time (24 hour) format string 102 public string ToUniversalString() 103 { 104 return String.Format( 105 "{0:D2}:{1:D2}:{2:D2}" , Hour, Minute, Second ); 106 } 107 108 // convert time to standard-time (12 hour) format string 109 public string ToStandardString() 110 { 111 return String.Format( "{0}:{1:D2}:{2:D2} {3}" , 112 ( ( Hour == 12 || Hour == 0 ) ? 12 : Hour % 12 ), 113 Minute, Second, ( Hour < 12 ? "AM" : "PM" ) ); 114 } 115 116 } // end class Time3
29. Date.cs 1 // Fig. 8.8: Date.cs 2 // Date class definition encapsulates month, day and year. 3 4 using System; 5 6 // Date class definition 7 public class Date 8 { 9 private int month; // 1-12 10 private int day; // 1-31 based on month 11 private int year; // any year 12 13 // constructor confirms proper value for month; 14 // call method CheckDay to confirm proper 15 // value for day 16 public Date( int theMonth, int theDay, int theYear ) 17 { 18 // validate month 19 if ( theMonth > 0 && theMonth <= 12 ) 20 month = theMonth; 21 22 else 23 { 24 month = 1 ; 25 Console.WriteLine( 26 "Month {0} invalid. Set to month 1." , theMonth ); 27 } 28 29 year = theYear; // could validate year 30 day = CheckDay( theDay ); // validate day 31 } 32 Constructor that receives the month, day and year arguments. Arguments are validated; if they are not valid, the corresponding member is set to a default value
30. Date.cs 33 // utility method confirms proper day value 34 // based on month and year 35 private int CheckDay( int testDay ) 36 { 37 int [] daysPerMonth = 38 { 0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 }; 39 40 // check if day in range for month 41 if ( testDay > 0 && testDay <= daysPerMonth[ month ] ) 42 return testDay; 43 44 // check for leap year 45 if ( month == 2 && testDay == 29 && 46 ( year % 400 == 0 || 47 ( year % 4 == 0 && year % 100 != 0 ) ) ) 48 return testDay; 49 50 Console.WriteLine( 51 "Day {0} invalid. Set to day 1." , testDay ); 52 53 return 1 ; // leave object in consistent state 54 } 55 56 // return date string as month/day/year 57 public string ToDateString() 58 { 59 return month + "/" + day + "/" + year; 60 } 61 62 } // end class Date Validate that the given month can have a given day number
31. Employee.cs 1 // Fig. 8.9: Employee.cs 2 // Employee class definition encapsulates employee's first name, 3 // last name, birth date and hire date. 4 5 using System; 6 7 // Employee class definition 8 public class Employee 9 { 10 private string firstName; 11 private string lastName; 12 private Date birthDate; 13 private Date hireDate; 14 15 // constructor initializes name, birth date and hire date 16 public Employee( string first, string last, 17 int birthMonth, int birthDay, int birthYear, 18 int hireMonth, int hireDay, int hireYear ) 19 { 20 firstName = first; 21 lastName = last; 22 23 // create new Date for Employee birth day 24 birthDate = new Date( birthMonth, birthDay, birthYear ); 25 hireDate = new Date( hireMonth, hireDay, hireYear ); 26 } 27 Constructor that initializes the employee’s name, birth date and hire date Two Date objects are members of the Employee class
32. Employee.cs 28 // convert Employee to String format 29 public string ToEmployeeString() 30 { 31 return lastName + ", " + firstName + 32 " Hired: " + hireDate.ToDateString() + 33 " Birthday: " + birthDate.ToDateString(); 34 } 35 36 } // end class Employee
33. CompositionTest.cs Program Output 1 // Fig. 8.10: CompositionTest.cs 2 // Demonstrate an object with member object reference. 3 4 using System; 5 using System.Windows.Forms; 6 7 // Composition class definition 8 class CompositionTest 9 { 10 // main entry point for application 11 static void Main( string [] args ) 12 { 13 Employee e = 14 new Employee( "Bob" , "Jones" , 7 , 24 , 1949 , 3 , 12 , 1988 ); 15 16 MessageBox.Show( e.ToEmployeeString(), 17 "Testing Class Employee" ); 18 19 } // end method Main 20 21 } // end class CompositionTest
34.
35. Time4.cs 1 // Fig. 8.11: Time4.cs 2 // Class Time2 provides overloaded constructors. 3 4 using System; 5 6 // Time4 class definition 7 public class Time4 8 { 9 private int hour; // 0-23 10 private int minute; // 0-59 11 private int second; // 0-59 12 13 // constructor 14 public Time4( int hour, int minute, int second ) 15 { 16 this .hour = hour; 17 this .minute = minute; 18 this .second = second; 19 } 20 21 // create string using this and implicit references 22 public string BuildString() 23 { 24 return "this.ToStandardString(): " + 25 this .ToStandardString() + 26 "ToStandardString(): " + ToStandardString(); 27 } 28 The this reference is used to set the class member variables to the constructor arguments The this reference is used to refer to an instance method
36. Time4.cs 29 // convert time to standard-time (12 hour) format string 30 public string ToStandardString() 31 { 32 return String.Format( "{0}:{1:D2}:{2:D2} {3}" , 33 ( ( this .hour == 12 || this .hour == 0 ) ? 12 : 34 this .hour % 12 ), this .minute, this .second, 35 ( this .hour < 12 ? "AM" : "PM" ) ); 36 } 37 38 } // end class Time4 The this reference is used to access member variables
37. ThisTest.cs Program Output 1 // Fig. 8.12: ThisTest.cs 2 // Using the this reference. 3 4 using System; 5 using System.Windows.Forms; 6 7 // ThisTest class definition 8 class Class1 9 { 10 // main entry point for application 11 static void Main( string [] args ) 12 { 13 Time4 time = new Time4( 12 , 30 , 19 ); 14 15 MessageBox.Show( time.BuildString(), 16 "Demonstrating the amp;quot;thisamp;quot; Reference" ); 17 } 18 }
38.
39.
40.
41. Employee.cs 1 // Fig. 8.13: Employee.cs 2 // Employee class contains static data and a static method. 3 4 using System; 5 6 // Employee class definition 7 public class Employee 8 { 9 private string firstName; 10 private string lastName; 11 private static int count; // Employee objects in memory 12 13 // constructor increments static Employee count 14 public Employee( string fName, string lName ) 15 { 16 firstName = fName; 17 lastName = lName; 18 19 ++count; 20 21 Console.WriteLine( " Employee object constructor: " + 22 firstName + " " + lastName + "; count = " + Count ); 23 } 24 25 // destructor decrements static Employee count 26 ~Employee() 27 { 28 --count; 29 30 Console.WriteLine( "Employee object destructor: " + 31 firstName + " " + lastName + "; count = " + Count ); 32 } 33 Employee destructor Decrease static member count, to signify that there is one less employee Update number of Employees
42. Employee.cs 34 // FirstName property 35 public string FirstName 36 { 37 get 38 { 39 return firstName; 40 } 41 } 42 43 // LastName property 44 public string LastName 45 { 46 get 47 { 48 return lastName; 49 } 50 } 51 52 // static Count property 53 public static int Count 54 { 55 get 56 { 57 return count; 58 } 59 } 60 61 } // end class Employee
43. StaticTest.cs 1 // Fig. 8.14: StaticTest.cs 2 // Demonstrating static class members. 3 4 using System; 5 6 // StaticTest class definition 7 class StaticTest 8 { 9 // main entry point for application 10 static void Main( string [] args ) 11 { 12 Console.WriteLine( "Employees before instantiation: " + 13 Employee.Count + "" ); 14 15 // create two Employees 16 Employee employee1 = new Employee( "Susan" , "Baker" ); 17 Employee employee2 = new Employee( "Bob" , "Jones" ); 18 19 Console.WriteLine( "Employees after instantiation: " + 20 "Employee.Count = " + Employee.Count + "" ); 21 22 // display the Employees 23 Console.WriteLine( "Employee 1: " + 24 employee1.FirstName + " " + employee1.LastName + 25 "Employee 2: " + employee2.FirstName + 26 " " + employee2.LastName + "" ); 27 28 // mark employee1 and employee1 objects for 29 // garbage collection 30 employee1 = null ; 31 employee2 = null ; 32 33 // force garbage collection 34 System.GC.Collect(); 35 Create 2 Employee objects Set Employee objects to null Force garbage collection
44. StaticTest.cs Program Output 36 Console.WriteLine( 37 "Employees after garbage collection: " + 38 Employee.Count ); 39 } 40 } Employees before instantiation: 0 Employee object constructor: Susan Baker; count = 1 Employee object constructor: Bob Jones; count = 2 Employees after instantiation: Employee.Count = 2 Employee 1: Susan Baker Employee 2: Bob Jones Employee object destructor: Bob Jones; count = 1 Employee object destructor: Susan Baker; count = 0 Employees after garbage collection: 2
45.
46. UsingConstAndReadOnly.cs 1 // Fig. 8.15: UsingConstAndReadOnly.cs 2 // Demonstrating constant values with const and readonly. 3 4 using System; 5 using System.Windows.Forms; 6 7 // Constants class definition 8 public class Constants 9 { 10 // PI is constant variable 11 public const double PI = 3.14159 ; 12 13 // radius is a constant variable 14 // that is uninitialized 15 public readonly int radius; 16 17 public Constants( int radiusValue ) 18 { 19 radius = radiusValue; 20 } 21 22 } // end class Constants 23 24 // UsingConstAndReadOnly class definition 25 public class UsingConstAndReadOnly 26 { 27 // method Main creates Constants 28 // object and displays it's values 29 static void Main( string [] args ) 30 { 31 Random random = new Random(); 32 33 Constants constantValues = 34 new Constants( random.Next( 1 , 20 ) ); 35 Constant variable PI Readonly variable radius; must be initialized in constructor Initialize readonly member radius
47. UsingConstAndReadOnly.cs Program Output 36 MessageBox.Show( "Radius = " + constantValues.radius + 37 "Circumference = " + 38 2 * Constants. PI * constantValues.radius, 39 "Circumference" ); 40 41 } // end method Main 42 43 } // end class UsingConstAndReadOnly
48.
49. IndexerTest.cs 1 // Fig. 8.10: IndexerTest.cs 2 // Indexers provide access to an object's members via a 3 // subscript operator. 4 5 using System; 6 using System.Drawing; 7 using System.Collections; 8 using System.ComponentModel; 9 using System.Windows.Forms; 10 using System.Data; 11 12 // Box class definition represents a box with length, 13 // width and height dimensions 14 public class Box 15 { 16 private string [] names = { "length" , "width" , "height" }; 17 private double [] dimensions = new double[ 3 ]; 18 19 // constructor 20 public Box( double length, double width, double height ) 21 { 22 dimensions[ 0 ] = length; 23 dimensions[ 1 ] = width; 24 dimensions[ 2 ] = height; 25 } 26 27 // access dimensions by index number 28 public double this[ int index ] 29 { 30 get 31 { 32 return ( index < 0 || index > dimensions.Length ) ? 33 -1 : dimensions[ index ]; 34 } 35 Indexer declaration; indexer receives an integer to specify which dimension is wanted The get index accessor If the index requested is out of bounds, return –1; otherwise, return the appropriate element
50. IndexerTest.cs 36 set 37 { 38 if ( index >= 0 && index < dimensions.Length ) 39 dimensions[ index ] = value; 40 } 41 42 } // end numeric indexer 43 44 // access dimensions by their names 45 public double this [ string name ] 46 { 47 get 48 { 49 // locate element to get 50 int i = 0 ; 51 52 while ( i < names.Length && 53 name.ToLower() != names[ i ] ) 54 i++; 55 56 return ( i == names.Length ) ? -1 : dimensions[ i ]; 57 } 58 59 set 60 { 61 // locate element to set 62 int i = 0 ; 63 64 while ( i < names.Length && 65 name.ToLower() != names[ i ] ) 66 i++; 67 The set accessor for the index Validate that the user wishes to set a valid index in the array and then set it Indexer that takes the name of the dimension as an argument
51. IndexerTest.cs 68 if ( i != names.Length ) 69 dimensions[ i ] = value; 70 } 71 72 } // end indexer 73 74 } // end class Box 75 76 // Class IndexerTest 77 public class IndexerTest : System.Windows.Forms.Form 78 { 79 private System.Windows.Forms.Label indexLabel; 80 private System.Windows.Forms.Label nameLabel; 81 82 private System.Windows.Forms.TextBox indexTextBox; 83 private System.Windows.Forms.TextBox valueTextBox; 84 85 private System.Windows.Forms.Button nameSetButton; 86 private System.Windows.Forms.Button nameGetButton; 87 88 private System.Windows.Forms.Button intSetButton; 89 private System.Windows.Forms.Button intGetButton; 90 91 private System.Windows.Forms.TextBox resultTextBox; 92 93 // required designer variable 94 private System.ComponentModel.Container components = null ; 95 96 private Box box; 97 98 // constructor 99 public IndexerTest() 100 { 101 // required for Windows Form Designer support 102 InitializeComponent();
52. IndexerTest.cs 103 104 // create block 105 box = new Box( 0.0 , 0.0 , 0.0 ); 106 } 107 108 // Visual Studio .NET generated code 109 110 // main entry point for application 111 [STAThread] 112 static void Main() 113 { 114 Application.Run( new IndexerTest() ); 115 } 116 117 // display value at specified index number 118 private void ShowValueAtIndex( string prefix, int index ) 119 { 120 resultTextBox.Text = 121 prefix + "box[ " + index + " ] = " + box[ index ]; 122 } 123 124 // display value with specified name 125 private void ShowValueAtIndex( string prefix, string name ) 126 { 127 resultTextBox.Text = 128 prefix + "box[ " + name + " ] = " + box[ name ]; 129 } 130 131 // clear indexTextBox and valueTextBox 132 private void ClearTextBoxes() 133 { 134 indexTextBox.Text = "" ; 135 valueTextBox.Text = "" ; 136 } 137 Use the get accessor of the indexer Use the set accessor of the indexer
53. IndexerTest.cs 138 // get value at specified index 139 private void intGetButton_Click( 140 object sender, System.EventArgs e ) 141 { 142 ShowValueAtIndex( 143 "get: " , Int32.Parse( indexTextBox.Text ) ); 144 ClearTextBoxes(); 145 } 146 147 // set value at specified index 148 private void intSetButton_Click( 149 object sender, System.EventArgs e ) 150 { 151 int index = Int32.Parse( indexTextBox.Text ); 152 box[ index ] = Double.Parse( valueTextBox.Text ); 153 154 ShowValueAtIndex( "set: " , index ); 155 ClearTextBoxes(); 156 } 157 158 // get value with specified name 159 private void nameGetButton_Click( 160 object sender, System.EventArgs e ) 161 { 162 ShowValueAtIndex( "get: " , indexTextBox.Text ); 163 ClearTextBoxes(); 164 } 165 Use integer indexer to get value Use integer indexer to set value Use string indexer to get value
54. IndexerTest.cs Program Output 166 // set value with specified name 167 private void nameSetButton_Click( 168 object sender, System.EventArgs e ) 169 { 170 box[ indexTextBox.Text ] = 171 Double.Parse( valueTextBox.Text ); 172 173 ShowValueAtIndex( "set: " , indexTextBox.Text ); 174 ClearTextBoxes(); 175 } 176 177 } // end class IndexerTest Before setting value by index number After setting value by index number Use string indexer to set value
55. IndexerTest.cs Program Output Before getting value by dimension name After getting value by dimension name Before setting value by dimension name
56. IndexerTest.cs Program Output After setting value by dimension name Before getting value by index number After getting value by index numbe r
57.
58.
59. TimeLibrary.cs 1 // Fig. 8.17: TimeLibrary.cs 2 // Placing class Time3 in an assembly for reuse. 3 4 using System; 5 6 namespace TimeLibrary 7 { 8 // Time3 class definition 9 public class Time3 10 { 11 private int hour; // 0-23 12 private int minute; // 0-59 13 private int second; // 0-59 14 15 // Time3 constructor initializes instance variables to 16 // zero to set default time to midnight 17 public Time3() 18 { 19 SetTime( 0 , 0 , 0 ); 20 } 21 22 // Time3 constructor: hour supplied, minute and second 23 // defaulted to 0 24 public Time3( int hour ) 25 { 26 SetTime( hour, 0 , 0 ); 27 } 28 29 // Time3 constructor: hour and minute supplied, second 30 // defaulted to 0 31 public Time3( int hour, int minute ) 32 { 33 SetTime( hour, minute, 0 ); 34 } 35
60. TimeLibrary.cs 36 // Time3 constructor: hour, minute and second supplied 37 public Time3( int hour, int minute, int second ) 38 { 39 SetTime( hour, minute, second ); 40 } 41 42 // Time3 constructor: initialize using another Time3 object 43 public Time3( Time3 time ) 44 { 45 SetTime( time.Hour, time.Minute, time.Second ); 46 } 47 48 // Set new time value in 24-hour format. Perform validity 49 // checks on the data. Set invalid values to zero. 50 public void SetTime( 51 int hourValue, int minuteValue, int secondValue ) 52 { 53 Hour = hourValue; 54 Minute = minuteValue; 55 Second = secondValue; 56 } 57 58 // property Hour 59 public int Hour 60 { 61 get 62 { 63 return hour; 64 } 65 66 set 67 { 68 hour = ( ( value >= 0 && value < 24 ) ? value : 0 ); 69 } 70
61. TimeLibrary.cs 71 } // end property Hour 72 73 // property Minute 74 public int Minute 75 { 76 get 77 { 78 return minute; 79 } 80 81 set 82 { 83 minute = ( ( value >= 0 && value < 60 ) ? value : 0 ); 84 } 85 86 } // end property Minute 87 88 // property Second 89 public int Second 90 { 91 get 92 { 93 return second; 94 } 95 96 set 97 { 98 second = ( ( value >= 0 && value < 60 ) ? value : 0 ); 99 } 100 101 } // end property Second 102
62. TimeLibrary.cs 103 // convert time to universal-time (24 hour) format string 104 public string ToUniversalString() 105 { 106 return String.Format( 107 "{0:D2}:{1:D2}:{2:D2}" , Hour, Minute, Second ); 108 } 109 110 // convert time to standard-time (12 hour) format string 111 public string ToStandardString() 112 { 113 return String.Format( "{0}:{1:D2}:{2:D2} {3}" , 114 ( ( Hour == 12 || Hour == 0 ) ? 12 : Hour % 12 ), 115 Minute, Second, ( Hour < 12 ? "AM" : "PM" ) ); 116 } 117 118 } // end class Time3 119 }
63.
64. 8.16 Namespaces and Assemblies Fig. 8.18 Simple Class Library.
65. AssemblyTest.cs Program Output 1 // Fig. 8.19: AssemblyTest.cs 2 // Using class Time3 from assembly TimeLibrary. 3 4 using System; 5 using TimeLibrary; 6 7 // AssemblyTest class definition 8 class AssemblyTest 9 { 10 // main entry point for application 11 static void Main( string [] args ) 12 { 13 Time3 time = new Time3( 13 , 27 , 6 ); 14 15 Console.WriteLine( 16 "Standard time: {0}Universal time: {1}" , 17 time.ToStandardString(), time.ToUniversalString() ); 18 } 19 } Standard time: 1:27:06 PM Universal time: 13:27:06 Reference the TimeLibrary namespace Use Time3 as usual
66.
67.
68. 8.17 Class View and Object Browser Fig. 8.20 Class View of class Time1 (Fig. 8.1) and class TimeTest (Fig. 8.2).
69. 8.17 Class View and Object Browser Fig. 8.21 Object Browser when user selects Object from Time1.cs . (part 1)
70. 8.17 Class View and Object Browser Fig. 8.21 Object Browser when user selects Object from Time1.cs . (part 1)