Google Answers Logo
View Question
 
Q: Program in C# : please help soon. ( No Answer,   0 Comments )
Question  
Subject: Program in C# : please help soon.
Category: Computers > Programming
Asked by: sean07-ga
List Price: $30.00
Posted: 04 Oct 2004 21:45 PDT
Expires: 04 Oct 2004 22:07 PDT
Question ID: 410435
Develop a library that adds two mixed currencies together and return a
US dollar amount. For example, adds 5 francs and 500 Yen together ( u
can include some other currecies also). The library should handle any
currency as long as the exchange rates are provided. ( you can get
some conversion rates at http://www.exchangerate.com/).

Clarification of Question by sean07-ga on 04 Oct 2004 22:05 PDT
The program should be written in C# in a way it can be tested using nUnit. 
Please also write the test cases..because without them this thing will
be incomplete. I'm giving an example of the test cases as well as a
program in C# , which can make it much easier for u. The program
checks and accepts only a four leter passwd "TEST". Here it goes(
first see the example of test cases and then the implementation
code...write test cases and implementation code for the given
problem):

Representative tests:
---------------------

using System;
using NUnit.Framework;

namespace Authentication
{
	/*
	 * Class to test Password
	 */
	[TestFixture]
	public class TestPassword
	{
		[Test]
		// Representative Tests For the method verify
		public void testRepVerifyMoreChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("TESTTEST"));
		}

		public void testRepVerifyLessChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("TES"));
		}
		public void testRepVerifyBlankSpace()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("   "));
		}
		public void testRepVerifyEmptyString()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify(""));
		}
		public void testRepVerifyCase()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("test"));
		}
		public void testRepVerifySpecialChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("T1#T"));
		}
		public void testRepVerifyNumeric()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("1234"));
		}
		public void testRepVerifyActual()
		{
			Password pw = new Password();
			Assert.IsTrue(pw.verify("TEST"));
		}


Implementation code:
-----------------------
using System;

namespace Authentication
{
	/* 
	 * The class Password, accepts a 4-letter string,
	 * and verifies it with passwd
	 */
	public class Password
	{
		private string passwd = "TEST";
		public bool verify(string s)
		{
			if(s.Length != 4)	return false;

			char[] c = s.ToCharArray();
			foreach(int ch in c)
			{
				if (ch >= 'A' && ch <='Z') 
					continue;
				return false;
			}
			/* 
			 * Implementation for 4c : passes all
			 * representative & exhaustive test cases
			 */
			/*
			char[] pwd = passwd.ToCharArray();
			for(int i=0; i<s.Length; i++)
			{
				if(c[i] != pwd[i])
					return false;
			}
			return true;
			*/

			/* 
			 * Implementation for 4c : passes all
			 * representative but FAILS exhaustive test cases
			 * It fails as the position of each characters are 
			 * not checked. So TETT, SETS .. all are treated as
			 * valid with the following code.
			 */			
			foreach(int ch in c)
			{
				if(passwd.IndexOf((char)ch) < 0) 
					return false;
			}
			return true;
		}
	}
}
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy