Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Info 1182 Project 4a Strings, Files, Simple Class Invictus William Ernest Henley (18491903). Out of the night that covers me, Black as the pit from

Info 1182 Project 4a Strings, Files, Simple Class

Invictus

William Ernest Henley (18491903).

Out of the night that covers me,

Black as the pit from pole to pole,

I thank whatever gods maybe

For my unconquerable soul.

In the fell clutch of circumstance

I have not winced nor cried aloud.

Under the bludgeonings of chance

My head is bloody but unbowed.

Beyond this place of wrath and tears

Looms but the Horror of the shade,

And yet the menace of the years

Finds and shall find me unafraid.

It matters not how strait the gate,

How charged with punishments the scroll,

I am the master of my fate:

I am the captain of my soul

Create a folder P4a. Create a class FilesAndStrings that contains the methods described below. When you are finished, zip up the project and submit thought to moodle.

  1. Using just the ElementAt, Length, and Substring string methods and the + (concatenate) operator, write a function that accepts a string s, a start position p, and a length l, and returns s with the characters starting in position p for a length of l removed. Dont forget that strings start at position 0. Thus (abcdefghijk, 2, 4) returns abghijk. Dont use any remove or similar built-in string gadget.

  1. Write a function that accepts a string s and a character c and returns the number of times c occurs in s.

  1. Write a function that accepts a string and returns its reverse. Thus reverse(abcdef) should return fedcba. Ideally, your function does not create an extra array. Dont use any built-in reverse string gadget.

  1. Using the following TextFile class, read in a string t that contains the invictus.txt file provided for this assignment. To be able to read the file, it must be placed into the /bin/debug folder right next to the .exe for the project. Apply the ToUpper string method to the string containing the contents of the textfile and then write the results out to a text file.

/****************************************************

* TextFileClass - David Beard

* reads and writes string to and from text file

* **************************************************/

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO; //note that we have included System.IO

namespace textFileClassSamplier

{

class TextFileClass

{

private string fileName;

/// constructor.FilePath may be absolute or relative.

/// if relative, it is contained inside the obj sub folder.

public TextFileClass(string _fileName)

{

fileName = _fileName;

}

/// GetStringFromTextFile - dvb

/// reads

public string GetStringFromTextFile()

{

string s = "";

if(fileName.Length >0)

{

StreamReader streamReader = new StreamReader(fileName);

s = streamReader.ReadToEnd();

streamReader.Close();

}

return s;

}

/// WriteStringToTextFile - dvb

/// Writes String to textfile. Assumes " " line feeds as returned

/// from textbox.

public void writeStringToTextFile(string s)

{

if(fileName.Length >0)

{

StreamWriter file = new StreamWriter(fileName);

file.WriteLine(s);

file.Close();

}

}

}

}

Rubric:

  1. Tasks 25 points each.
  2. Style -20
    1. Block comment with name, date, and good sentence(s)
    2. Good variable names

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

Relational Contexts in Organizations

Answered: 1 week ago