
answer in c# console application.
Output:

Form.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
namespace FileOperationForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<Person> list = new List<Person>();
private void button1_Click(object sender, EventArgs e)
{
Person obj = new Person();
obj.firstname = textBox1.Text;
obj.lastName = textBox2.Text;
obj.phoneNumber = textBox3.Text;
if(radioButton1.Checked==true)
{
obj.male = true;
}
else
{
obj.female = true;
}
list.Add(obj);
using (StreamWriter writer = new
StreamWriter("..\\..\\TextFile1.txt", true))
{
writer.WriteLine(obj.firstname +
obj.lastName+obj.phoneNumber);
if(obj.male==true)
{
writer.WriteLine("Male");
}
else
{
writer.WriteLine("FeMale");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
for(int i=0;i<list.Count;i++)
{
richTextBox1.Text += list[i].firstname + list[i].lastName +
list[i].phoneNumber;
if(list[i].male==true)
{
richTextBox1.Text += "male";
}
else
{
richTextBox1.Text += "female";
}
richTextBox1.Text += Environment.NewLine;
}
}
private void button3_Click(object sender, EventArgs e)
{
using (StreamReader reader = new
StreamReader("..\\..\\TextFile1.txt"))
{
while (true)
{
string line = reader.ReadLine();
if (line == null)
{
break;
}
}
}
}
}
class Person
{
public string firstname;
public string lastName;
public string phoneNumber;
public bool female;
public bool male;
}
}
Designer code:
namespace FileOperationForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should
be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
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 InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(40, 46);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 13);
this.label1.TabIndex = 0;
this.label1.Text = "First Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(40, 95);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Last Name";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(40, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(78, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Phone Number";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(127, 46);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 3;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(127, 92);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 4;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(139, 152);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 5;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(92,
223);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(48, 17);
this.radioButton1.TabIndex = 6;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Male";
this.radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(297,
223);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(60, 17);
this.radioButton2.TabIndex = 7;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "FeMale";
this.radioButton2.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(43, 314);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 8;
this.button1.Text = "Add ";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new
System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(216, 314);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 9;
this.button2.Text = "Display";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new
System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(395, 314);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 10;
this.button3.Text = "Read";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new
System.EventHandler(this.button3_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(315,
46);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(192, 151);
this.richTextBox1.TabIndex = 11;
this.richTextBox1.Text = "";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(572, 449);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.RichTextBox richTextBox1;
}
}
Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.
answer in c# console application. File l/O Create a Person class (firstName, lastName, phoneNumber, gender (Use...
DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...
Write in C++ 1. Use the following Person class (Person.cpp, Person.h). You will be writing Person objects to a random access file. --------------------- Person.cpp--------------------------------- // Class Person stores customer's credit information. #include <string> #include "Person.h" using namespace std; // default Person constructor Person::Person( int idValue, string lastNameValue, string firstNameValue, int AgeValue ) { setID( idValue ); setLastName( lastNameValue ); setFirstName( firstNameValue ); setAge( AgeValue ); } // end Person constructor // get id value int Person::getID() const { return id;...
Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...
1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of a.Duck Typing b.Separation of Concerns c.Functional Programming d.Polymorphism e.Enumerated Values 2-JUnit assertions should be designed so that they a.Fail (ie, are false) if...
PYTHON 3 Object Oriented Programming
***a9q3.py file below***
class GradeItem(object):
# A Grade Item is anything a course uses in a grading scheme,
# like a test or an assignment. It has a score, which is assessed by
# an instructor, and a maximum value, set by the instructor, and a weight,
# which defines how much the item counts towards a final grade.
def __init__(self, weight, scored=None, out_of=None):
"""
Purpose:
Initialize the GradeItem object.
Preconditions:
:param weight: the weight...
Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...
This is a C++ program Instructions Design a class named PersonData with the following member variables declared as strings: lastName firstName address city state zip phone Create 3 constructors; a default constructor, a constructor that accepts the first and last name member variables, and a constructor that accepts all member variables. Write the appropriate accessor/getter and mutator/setter functions for these member variables. Create a method within this class called getFullName() that returns the person's first and last names as a...