Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A . a)Use class Time2 from Fig. 10.5 to create a C# class library project that can be used in a console project application

Part A.

a)Use class Time2 from Fig. 10.5 to create a C# class library project that can be used in a console project application (you can cut and paste the code from the book example).

b)Use the console application from Fig 10.6 to create a console project that will use the class library (will need to create a reference to the class library dll) created in a).

c)Create a new class Time2 based on Fig. 10.5 but representing the time internally as the number of seconds since midnight rather than three integer values for hour, minutes and seconds and create a second class library project with your new implementation of class Time2.

d)Show that the same application created in b) can use either class library (the one created in a) or the one created in c) without any change to the test application. Turn in source code and schedule a demo with our TA the week the program is due to show a test of your program running with a) the original class and b) with the modified class, both should produce the same results except for maybe the toString and toUniversal string adding a short message indicating which library file is being used. You should run THE SAME TEST PROGRAM (b) twice, once using each implementations of Time2 (the old and the new).

Part B.

a)Modify both classes (original Time2 and your new class produced in part A.c) to include two overloaded methods that can add time to the time objects as follows:

one method will add a value of time received as three integers representing number of hours, minutes and seconds to be added.

public void addtime(int h, int m, int s) { ... }

the other one will add a value of time received as another Time2 object.

Public void addtime( Time2 atime ) { }

b)Modify the test program from part A.b) to show that time is added correctly. What should your classes do when adding time takes the time over the 23:59;59 max time in a day? Turn in your VS solution and do a demo showing the modified test program running with a) the modified original class and b) with the modified new class, both test runs should produce the same results.

Answer the following questions:

1.Which set of methods was easier to write? The new methods for the original Time2 class or the new methods for the reeingineered Time2 class?

2.Can the overloaded methods in either class handle negative values as input?

3.How difficult would it be to add such capability to either class?

Part C. Write a derived class time2tz based on either one of your modified classes (from part B) which allows you to maintain the time zone in addition to the time. Allowed values for time zone include: EST, CST, MST, PST. You will need to override the toString and the toUniversalString methods to return the time including its corresponding time zone. Your class should include at least 3 constructors (your choice). Turn in your source code and do a demo showing your testing of the class (with a modified test program (from part B.b) where you create several time objects and several time zoned objects and show the polymorphic behavior of either the toString or the toUniversalString methods.

Part D. Create a new test console application which should do the following:

The data for the entered time objects should be kept in a list of time2 objects ( List) so you can use LINQ to run the queries that will produce the reports

Start with a loop to ask the user to enter data for a number of time2 and time2tz objects. The user should be given the choice to keep entering data or stop after data for each object is entered, something like this:

Which type of object you wish to enter?:

1 time2

2 time2tz

3 Stop entering data

1

Enter Hours:

6

Enter Minutes:

25

Enter Seconds:

50

Which type of object you wish to enter?:

1 time2

2 time2tz

3 Stop entering data

2

Enter Hours:

15

Enter Minutes:

12

Enter Seconds:

24

Enter timezone

CST

Which type of object you wish to enter?:

1 time2

2 time2tz

3 Stop entering data

3

What report do you want:

1 All objects

2 All objects with AM times

3 All objects with PM times

4 - QUIT

Display the list of requested objects in increasing order

After the report is produced, the user should have the choice to produce another report or quit.

Have your classes throw an exception when adding time takes the time value to more than 23:59:59 and modify the Test program to handle the exception.

Your programs should follow good software engineering practices, i.e., all constructors should call the fully parameterized constructor, constructors in the derived class constructor should call the base class constructor appropriately to initialize the base class state, use of properties, if your derived class overrides a method, it should call the base class version of the method to do partial work and OF COURSE use of private variables AND ONLY private variables in your classes!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

1. What might have led to the misinformation?

Answered: 1 week ago

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago