Problem with TestOut's C# For Programmers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PSL

    #1

    Problem with TestOut's C# For Programmers

    Hi,

    I am going through the training C# For Programmers made by TestOut and
    like the presentation. The only problem is that this tutorial has a nastie bug
    that renders this software practically useless. I've tried using TestOut's
    support form to submit the problem but each time I submit I get a "ERROR
    MESSAGE: Could not modify CSV file.".

    My problem is that after I run a simulation, the simualtion report comes up.
    One section of this is called "Correct Answer". This section contains the
    text "To view the correct answer, click here." (click here is hyperlinked).
    Clicking on this hyperlink never brings up the solution. This makes it
    impossible for me to check answers.

    I got stuck on a question regarding structures. Any help would be greatly
    appreciated.

    Regards,
    Paul


    ------------------------------------------------------------------------------------
    Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's Resource site.
    Get your free weblog, download free apps, read tutorials, and more.
  • Lebesgue

    #2
    Re: Problem with TestOut's C# For Programmers

    What internet browser are you using? What spyware protection / firewall
    software are you using (these can block popup windows)?
    And finally, since this is a C# group, what was the question you got stuck
    on? Maybe people here could tell you what the correct answer is and why-

    "PSL" <psl66_uk@(at )@-NOSPAM-hotmail.(dot).c om> wrote in message
    news:551bff44-b75e-4843-96fc-5654a2a76f9a@ca rnage.santry.co m...[color=blue]
    > Hi,
    >
    > I am going through the training C# For Programmers made by TestOut and
    > like the presentation. The only problem is that this tutorial has a nastie
    > bug
    > that renders this software practically useless. I've tried using TestOut's
    > support form to submit the problem but each time I submit I get a "ERROR
    > MESSAGE: Could not modify CSV file.".
    >
    > My problem is that after I run a simulation, the simualtion report comes
    > up.
    > One section of this is called "Correct Answer". This section contains the
    > text "To view the correct answer, click here." (click here is
    > hyperlinked).
    > Clicking on this hyperlink never brings up the solution. This makes it
    > impossible for me to check answers.
    >
    > I got stuck on a question regarding structures. Any help would be greatly
    > appreciated.
    >
    > Regards,
    > Paul
    >
    >
    > ------------------------------------------------------------------------------------
    > Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's
    > Resource site.
    > Get your free weblog, download free apps, read tutorials, and more.[/color]


    Comment

    • psl66_uk@hotmail.com

      #3
      Re: Problem with TestOut's C# For Programmers

      "Lebesgue" <nos...@spam.jp > wrote:
      [color=blue]
      >What internet browser are you using? What spyware protection / firewall
      >software are you using (these can block popup windows)?
      >And finally, since this is a C# group, what was the question you got stuck
      >on? Maybe people here could tell you what the correct answer is and why-[/color]

      The reason for asking here is that maybe someone has encountered this
      problem and figured out a solution (it would avoid me asking :-).

      This is the TestOut Question

      Q:

      You have been asked to create a data type that can easily store and
      convert distances of various kinds. Because a distance only consists of
      a length value and associated units, a struct type seems to be a good
      fit.

      Do the following to create the needed struct data type:

      Create a new class file called Distance.
      Define a public enum called DistanceUnits with Inches, Feet, and Meters
      as named values.
      Create a public struct called Distance.
      Define a public field in the Distance struct called Value of type
      double.
      Define a public field in the Distance struct called Units of type
      DistanceUnits.
      Define a constructor in Distance that will set the Value and Units
      fields (in that order).
      Define a public method in Distance called Convert that takes a
      parameter of type DistanceUnits that identifies a new unit of measure.
      The Convert method should do the following:
      Convert the Value field from the current instance to the new unit of
      measure identified by the parameter.
      Create a new instance of Distance setting the Value and Units in the
      new instance based on the converted value and the new unit of measure.
      Return the new Distance struct.
      A simple way to convert from one unit of measure to another is to use a
      switch statement to convert the current value to an intermediate value
      in known units (such as inches). Then use a second switch statement to
      convert the intermediate value to the requested new unit of measure.

      Use the following conversion values: 12 inches = 1 foot; 39.37 inches =
      1 meter.

      Run the test program to verify your code. Enter a distance value in the
      edit box and select an original and new unit of measure from the drop
      down list boxes. The converted distance should appear.


      The simulation has a form consisting of the following:

      Type: Label, Name: Label1, Text: Distance:
      Type: TextBox, Name: valueTextBox, Text: 0
      Type: ComboBox, Name: fromComboBox
      Type: Label, Name: valueLabel, Text: ?
      Type: ComboBox, Name: toComboBox

      The code behind the form is the one below:

      using System;
      using System.Drawing;
      using System.Collecti ons;
      using System.Componen tModel;
      using System.Windows. Forms;
      using System.Data;

      namespace Structs
      {
      /// <summary>
      /// Summary description for Form1.
      /// </summary>
      public class Form1 : System.Windows. Forms.Form
      {
      private System.Windows. Forms.Label Label1;
      private System.Windows. Forms.TextBox valueTextBox;
      private System.Windows. Forms.ComboBox fromComboBox;
      private System.Windows. Forms.Label Label2;
      private System.Windows. Forms.Label valueLabel;
      private System.Windows. Forms.ComboBox toComboBox;
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.Componen tModel.Containe r components = null;

      public Form1()
      {
      //
      // Required for Windows Form Designer support
      //
      InitializeCompo nent();

      //
      // TODO: Add any constructor code after InitializeCompo nent call
      //
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose( bool disposing )
      {
      if( disposing )
      {
      if (components != null)
      {
      components.Disp ose();
      }
      }
      base.Dispose( disposing );
      }

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeCompo nent()
      {
      this.components = new System.Componen tModel.Containe r();
      this.toComboBox = new System.Windows. Forms.ComboBox( );
      this.valueLabel = new System.Windows. Forms.Label();
      this.Label2 = new System.Windows. Forms.Label();
      this.fromComboB ox = new System.Windows. Forms.ComboBox( );
      this.valueTextB ox = new System.Windows. Forms.TextBox() ;
      this.Label1 = new System.Windows. Forms.Label();
      this.SuspendLay out();
      //
      // toComboBox
      //
      this.toComboBox .DropDownStyle =
      System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
      this.toComboBox .Location = new System.Drawing. Point(328, 16);
      this.toComboBox .Name = "toComboBox ";
      this.toComboBox .Size = new System.Drawing. Size(80, 21);
      this.toComboBox .TabIndex = 6;
      this.toComboBox .SelectedIndexC hanged += new
      System.EventHan dler(ComboBox_S electedIndexCha nged);
      //
      // valueLabel
      //
      this.valueLabel .TextAlign =
      System.Drawing. ContentAlignmen t.TopCenter;
      this.valueLabel .Location = new System.Drawing. Point(248, 16);
      this.valueLabel .Name = "valueLabel ";
      this.valueLabel .Size = new System.Drawing. Size(72, 23);
      this.valueLabel .TabIndex = 5;
      this.valueLabel .Text = "?";
      //
      // Label2
      //
      this.Label2.Tex tAlign = System.Drawing. ContentAlignmen t.TopCenter;
      this.Label2.Loc ation = new System.Drawing. Point(232, 16);
      this.Label2.Nam e = "Label2";
      this.Label2.Siz e = new System.Drawing. Size(16, 24);
      this.Label2.Tab Index = 4;
      this.Label2.Tex t = "=";
      //
      // fromComboBox
      //
      this.fromComboB ox.DropDownStyl e =
      System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
      this.fromComboB ox.Location = new System.Drawing. Point(152, 16);
      this.fromComboB ox.Name = "fromComboB ox";
      this.fromComboB ox.Size = new System.Drawing. Size(80, 21);
      this.fromComboB ox.TabIndex = 3;
      this.fromComboB ox.SelectedInde xChanged += new
      System.EventHan dler(ComboBox_S electedIndexCha nged);
      //
      // valueTextBox
      //
      this.valueTextB ox.Text = "0";
      this.valueTextB ox.TextAlign =
      System.Windows. Forms.Horizonta lAlignment.Cent er;
      this.valueTextB ox.Location = new System.Drawing. Point(72, 16);
      this.valueTextB ox.Name = "valueTextB ox";
      this.valueTextB ox.Size = new System.Drawing. Size(72, 20);
      this.valueTextB ox.TabIndex = 2;
      this.valueTextB ox.TextChanged += new
      System.EventHan dler(ComboBox_S electedIndexCha nged);
      //
      // Label1
      //
      this.Label1.Loc ation = new System.Drawing. Point(16, 16);
      this.Label1.Nam e = "Label1";
      this.Label1.Siz e = new System.Drawing. Size(56, 23);
      this.Label1.Tab Index = 1;
      this.Label1.Tex t = "Distance:" ;
      //
      // Form1
      //
      this.ClientSize = new System.Drawing. Size(424, 54);
      this.Controls.A dd(this.toCombo Box);
      this.Controls.A dd(this.valueLa bel);
      this.Controls.A dd(this.Label2) ;
      this.Controls.A dd(this.fromCom boBox);
      this.Controls.A dd(this.valueTe xtBox);
      this.Controls.A dd(this.Label1) ;
      this.Text = "Distance Convert";
      this.Load += new System.EventHan dler(Form1_Load );
      this.ResumeLayo ut();
      }
      #endregion

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main()
      {
      Application.Run (new Form1());
      }

      private void Form1_Load(obje ct sender, System.EventArg s e)
      {
      foreach ( string s in Enum.GetNames(t ypeof(DistanceU nits)) )
      {
      fromComboBox.It ems.Add(s);
      toComboBox.Item s.Add(s);
      }
      fromComboBox.Se lectedIndex = 0;
      toComboBox.Sele ctedIndex = 0;
      }

      private void ComboBox_Select edIndexChanged( object sender,
      System.EventArg s e)
      {
      try
      {
      Distance inD = new Distance(Conver t.ToDouble(valu eTextBox.Text),
      (DistanceUnits) fromComboBox.Se lectedIndex);
      Distance outD =
      inD.Convert((Di stanceUnits)toC omboBox.Selecte dIndex);
      valueLabel.Text = String.Format(" {0:0.#####}", outD.Value);
      }
      catch
      {
      valueLabel.Text = "?";
      }
      }
      }
      }


      Thank you in anticipation.

      Comment

      • Lebesgue

        #4
        Re: Problem with TestOut's C# For Programmers

        Thanks for posting the whole question. What's your specific problem? Since
        this is a very basic task, I'm afraid you may have problems with language
        basics, and in this case, just giving you just a plain answer would be of no
        use to you

        <psl66_uk@hotma il.com> wrote in message
        news:1137345590 .697903.167640@ z14g2000cwz.goo glegroups.com.. .[color=blue]
        > "Lebesgue" <nos...@spam.jp > wrote:
        >[color=green]
        >>What internet browser are you using? What spyware protection / firewall
        >>software are you using (these can block popup windows)?
        >>And finally, since this is a C# group, what was the question you got stuck
        >>on? Maybe people here could tell you what the correct answer is and why-[/color]
        >
        > The reason for asking here is that maybe someone has encountered this
        > problem and figured out a solution (it would avoid me asking :-).
        >
        > This is the TestOut Question
        >
        > Q:
        >
        > You have been asked to create a data type that can easily store and
        > convert distances of various kinds. Because a distance only consists of
        > a length value and associated units, a struct type seems to be a good
        > fit.
        >
        > Do the following to create the needed struct data type:
        >
        > Create a new class file called Distance.
        > Define a public enum called DistanceUnits with Inches, Feet, and Meters
        > as named values.
        > Create a public struct called Distance.
        > Define a public field in the Distance struct called Value of type
        > double.
        > Define a public field in the Distance struct called Units of type
        > DistanceUnits.
        > Define a constructor in Distance that will set the Value and Units
        > fields (in that order).
        > Define a public method in Distance called Convert that takes a
        > parameter of type DistanceUnits that identifies a new unit of measure.
        > The Convert method should do the following:
        > Convert the Value field from the current instance to the new unit of
        > measure identified by the parameter.
        > Create a new instance of Distance setting the Value and Units in the
        > new instance based on the converted value and the new unit of measure.
        > Return the new Distance struct.
        > A simple way to convert from one unit of measure to another is to use a
        > switch statement to convert the current value to an intermediate value
        > in known units (such as inches). Then use a second switch statement to
        > convert the intermediate value to the requested new unit of measure.
        >
        > Use the following conversion values: 12 inches = 1 foot; 39.37 inches =
        > 1 meter.
        >
        > Run the test program to verify your code. Enter a distance value in the
        > edit box and select an original and new unit of measure from the drop
        > down list boxes. The converted distance should appear.
        >
        >
        > The simulation has a form consisting of the following:
        >
        > Type: Label, Name: Label1, Text: Distance:
        > Type: TextBox, Name: valueTextBox, Text: 0
        > Type: ComboBox, Name: fromComboBox
        > Type: Label, Name: valueLabel, Text: ?
        > Type: ComboBox, Name: toComboBox
        >
        > The code behind the form is the one below:
        >
        > using System;
        > using System.Drawing;
        > using System.Collecti ons;
        > using System.Componen tModel;
        > using System.Windows. Forms;
        > using System.Data;
        >
        > namespace Structs
        > {
        > /// <summary>
        > /// Summary description for Form1.
        > /// </summary>
        > public class Form1 : System.Windows. Forms.Form
        > {
        > private System.Windows. Forms.Label Label1;
        > private System.Windows. Forms.TextBox valueTextBox;
        > private System.Windows. Forms.ComboBox fromComboBox;
        > private System.Windows. Forms.Label Label2;
        > private System.Windows. Forms.Label valueLabel;
        > private System.Windows. Forms.ComboBox toComboBox;
        > /// <summary>
        > /// Required designer variable.
        > /// </summary>
        > private System.Componen tModel.Containe r components = null;
        >
        > public Form1()
        > {
        > //
        > // Required for Windows Form Designer support
        > //
        > InitializeCompo nent();
        >
        > //
        > // TODO: Add any constructor code after InitializeCompo nent call
        > //
        > }
        >
        > /// <summary>
        > /// Clean up any resources being used.
        > /// </summary>
        > protected override void Dispose( bool disposing )
        > {
        > if( disposing )
        > {
        > if (components != null)
        > {
        > components.Disp ose();
        > }
        > }
        > base.Dispose( disposing );
        > }
        >
        > #region Windows Form Designer generated code
        > /// <summary>
        > /// Required method for Designer support - do not modify
        > /// the contents of this method with the code editor.
        > /// </summary>
        > private void InitializeCompo nent()
        > {
        > this.components = new System.Componen tModel.Containe r();
        > this.toComboBox = new System.Windows. Forms.ComboBox( );
        > this.valueLabel = new System.Windows. Forms.Label();
        > this.Label2 = new System.Windows. Forms.Label();
        > this.fromComboB ox = new System.Windows. Forms.ComboBox( );
        > this.valueTextB ox = new System.Windows. Forms.TextBox() ;
        > this.Label1 = new System.Windows. Forms.Label();
        > this.SuspendLay out();
        > //
        > // toComboBox
        > //
        > this.toComboBox .DropDownStyle =
        > System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
        > this.toComboBox .Location = new System.Drawing. Point(328, 16);
        > this.toComboBox .Name = "toComboBox ";
        > this.toComboBox .Size = new System.Drawing. Size(80, 21);
        > this.toComboBox .TabIndex = 6;
        > this.toComboBox .SelectedIndexC hanged += new
        > System.EventHan dler(ComboBox_S electedIndexCha nged);
        > //
        > // valueLabel
        > //
        > this.valueLabel .TextAlign =
        > System.Drawing. ContentAlignmen t.TopCenter;
        > this.valueLabel .Location = new System.Drawing. Point(248, 16);
        > this.valueLabel .Name = "valueLabel ";
        > this.valueLabel .Size = new System.Drawing. Size(72, 23);
        > this.valueLabel .TabIndex = 5;
        > this.valueLabel .Text = "?";
        > //
        > // Label2
        > //
        > this.Label2.Tex tAlign = System.Drawing. ContentAlignmen t.TopCenter;
        > this.Label2.Loc ation = new System.Drawing. Point(232, 16);
        > this.Label2.Nam e = "Label2";
        > this.Label2.Siz e = new System.Drawing. Size(16, 24);
        > this.Label2.Tab Index = 4;
        > this.Label2.Tex t = "=";
        > //
        > // fromComboBox
        > //
        > this.fromComboB ox.DropDownStyl e =
        > System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
        > this.fromComboB ox.Location = new System.Drawing. Point(152, 16);
        > this.fromComboB ox.Name = "fromComboB ox";
        > this.fromComboB ox.Size = new System.Drawing. Size(80, 21);
        > this.fromComboB ox.TabIndex = 3;
        > this.fromComboB ox.SelectedInde xChanged += new
        > System.EventHan dler(ComboBox_S electedIndexCha nged);
        > //
        > // valueTextBox
        > //
        > this.valueTextB ox.Text = "0";
        > this.valueTextB ox.TextAlign =
        > System.Windows. Forms.Horizonta lAlignment.Cent er;
        > this.valueTextB ox.Location = new System.Drawing. Point(72, 16);
        > this.valueTextB ox.Name = "valueTextB ox";
        > this.valueTextB ox.Size = new System.Drawing. Size(72, 20);
        > this.valueTextB ox.TabIndex = 2;
        > this.valueTextB ox.TextChanged += new
        > System.EventHan dler(ComboBox_S electedIndexCha nged);
        > //
        > // Label1
        > //
        > this.Label1.Loc ation = new System.Drawing. Point(16, 16);
        > this.Label1.Nam e = "Label1";
        > this.Label1.Siz e = new System.Drawing. Size(56, 23);
        > this.Label1.Tab Index = 1;
        > this.Label1.Tex t = "Distance:" ;
        > //
        > // Form1
        > //
        > this.ClientSize = new System.Drawing. Size(424, 54);
        > this.Controls.A dd(this.toCombo Box);
        > this.Controls.A dd(this.valueLa bel);
        > this.Controls.A dd(this.Label2) ;
        > this.Controls.A dd(this.fromCom boBox);
        > this.Controls.A dd(this.valueTe xtBox);
        > this.Controls.A dd(this.Label1) ;
        > this.Text = "Distance Convert";
        > this.Load += new System.EventHan dler(Form1_Load );
        > this.ResumeLayo ut();
        > }
        > #endregion
        >
        > /// <summary>
        > /// The main entry point for the application.
        > /// </summary>
        > [STAThread]
        > static void Main()
        > {
        > Application.Run (new Form1());
        > }
        >
        > private void Form1_Load(obje ct sender, System.EventArg s e)
        > {
        > foreach ( string s in Enum.GetNames(t ypeof(DistanceU nits)) )
        > {
        > fromComboBox.It ems.Add(s);
        > toComboBox.Item s.Add(s);
        > }
        > fromComboBox.Se lectedIndex = 0;
        > toComboBox.Sele ctedIndex = 0;
        > }
        >
        > private void ComboBox_Select edIndexChanged( object sender,
        > System.EventArg s e)
        > {
        > try
        > {
        > Distance inD = new Distance(Conver t.ToDouble(valu eTextBox.Text),
        > (DistanceUnits) fromComboBox.Se lectedIndex);
        > Distance outD =
        > inD.Convert((Di stanceUnits)toC omboBox.Selecte dIndex);
        > valueLabel.Text = String.Format(" {0:0.#####}", outD.Value);
        > }
        > catch
        > {
        > valueLabel.Text = "?";
        > }
        > }
        > }
        > }
        >
        >
        > Thank you in anticipation.
        >[/color]


        Comment

        • psl66_uk@hotmail.com

          #5
          Re: Problem with TestOut's C# For Programmers

          I think that there is an error in the question. I only managed to get
          the code to compile when the class name had a different name to the
          struct.
          Once I changed the name of one of the items it worked.

          Thank you for the interest you have shown.
          Regards,
          PSL

          Lebesgue" <nos...@spam. jp wrote:[color=blue]
          >Thanks for posting the whole question. What's your specific problem? Since
          >this is a very basic task, I'm afraid you may have problems with language
          >basics, and in this case, just giving you just a plain answer would be of no
          >use to you[/color]

          Comment

          Working...