Joriku
Joriku
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
So, those are the things I'll be working on in the new project
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
So, the things left was: - Binear search - A sorting system
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Got the finals in 2 days only
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Yeah, starting a new project to finish up things and get some more repitation for the grounds
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Yeah, I took 4 out of 6 extra parts. Sadly, had not time for the other two so I can't get an A, but at least a C/B
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Sorry, didn't see this. It's turned in, had till yesterday 23.59
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
And I am done, finished up this task. I am not going for that A. Screw it, too complex xD Thank you both for your help, it's been extremely useful and took hours extra of my already 4 days into this project. Leaving the code public here, in case any one wants to look through it or needs it in the future.
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Currently:
// Remove a post
int removePostUserInput;
Console.Clear();
Console.WriteLine("Which post do you want to remove?");
// Print out all available posts as an option to select post.
for (int i = 0; i < myBlogVectorList.Count; i++)
{
Console.WriteLine("ID " + (i + 1) + ": " + myBlogVectorList[i][0]);
}
if (int.TryParse(Console.ReadLine(), out removePostUserInput))
{
// Remove 3 indexes based on ID
} else {
Console.WriteLine("Wrong input.");
}
// Remove a post
int removePostUserInput;
Console.Clear();
Console.WriteLine("Which post do you want to remove?");
// Print out all available posts as an option to select post.
for (int i = 0; i < myBlogVectorList.Count; i++)
{
Console.WriteLine("ID " + (i + 1) + ": " + myBlogVectorList[i][0]);
}
if (int.TryParse(Console.ReadLine(), out removePostUserInput))
{
// Remove 3 indexes based on ID
} else {
Console.WriteLine("Wrong input.");
}
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Posting the whole code since a lot has changed since last time.
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Alright, let's see. How would I do to print out all existing blogs. Give them a number by taking 3 indexes for each as 1 then the next 3 indexes for number 2. So Create an ID for the stories? This is to be able to remove a post by index 0 (title) text (index 1) and it's date (index 2) for each an every post. A simple remove function. Then this will come in handy while allowing to edit that specific title or text aswell. Then just update the edit date by .new
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Uhm, caugh, caugh. Just bad mobile harold
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Update: Added dates
static string[] saveBlogPost()
{
// Taking care of the add post function, returning with blogPost which can be used in main function.
// Set sequential for 2 temp strings, adds to list inside main function later.
string[] blogPost = new string[3];
Console.WriteLine("Enter a blog title:");
blogPost[0] = Console.ReadLine(); // Adds userInput to index 0
Thread.Sleep(1000);
Console.WriteLine("Enter the text for your blog post:");
blogPost[1] = Console.ReadLine(); // Adds userInput to index 1
blogPost[2] = DateTime.Now.ToString(); // Adds current time string to index 2
Console.Clear();
Console.WriteLine("Success! your title is: " + blogPost[0] + " and your blog text is: " + blogPost[1]); // Prints out set title and text
Console.WriteLine("Your blog is now saved!");
return blogPost;
}
static string[] saveBlogPost()
{
// Taking care of the add post function, returning with blogPost which can be used in main function.
// Set sequential for 2 temp strings, adds to list inside main function later.
string[] blogPost = new string[3];
Console.WriteLine("Enter a blog title:");
blogPost[0] = Console.ReadLine(); // Adds userInput to index 0
Thread.Sleep(1000);
Console.WriteLine("Enter the text for your blog post:");
blogPost[1] = Console.ReadLine(); // Adds userInput to index 1
blogPost[2] = DateTime.Now.ToString(); // Adds current time string to index 2
Console.Clear();
Console.WriteLine("Success! your title is: " + blogPost[0] + " and your blog text is: " + blogPost[1]); // Prints out set title and text
Console.WriteLine("Your blog is now saved!");
return blogPost;
}
And printing out as blogPost[2]
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Questions: What can go wrong here, and is this acceptable as a linear search method? Then, what I think this does to check If I am correct in most parts: It takes the users input, searches loops through the vector list to find the search word. Ignores the ordinal case rule skipping need of toLower/Upper. Checks if both [0, 1] index are true and searches for a word match. And if it doesn't exist, performs code below and informs that no character in the user's search matches a title nor text
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
So far, I updated the code to this
case 2:
// Allow a user to search for stored blog post.
Console.Write("Enter a search word:\n");
string searchWord = Console.ReadLine(); // Creates variable for searchWord
bool search = false; // If search is true or false

// blog instead of item
foreach (string[] blog in myBlogVectorList) // loops through vectorList to find the searchword
{
if (blog[0].IndexOf(searchWord, StringComparison.OrdinalIgnoreCase) >= 0 // StringComparison.OrdinalIgnoreCase, ignores using toUpper or toLower. Words treated as equals.
|| blog[1].IndexOf(searchWord, StringComparison.OrdinalIgnoreCase) >= 0) // || - if true and true, if both are true.
{
// searches for wordmatch in both title and text
Console.WriteLine("Title: " + blog[0] + "\nText: " + blog[1] + "\n-------------------------"); // Writes out title and text with a seperation
search = true;
}

}
if (!search) // if searchword does not exist in vectorList
{
Console.WriteLine("Your search has failed!" + "\nNo blog exists with either character: " + searchWord.Substring(0));
}
break;
case 2:
// Allow a user to search for stored blog post.
Console.Write("Enter a search word:\n");
string searchWord = Console.ReadLine(); // Creates variable for searchWord
bool search = false; // If search is true or false

// blog instead of item
foreach (string[] blog in myBlogVectorList) // loops through vectorList to find the searchword
{
if (blog[0].IndexOf(searchWord, StringComparison.OrdinalIgnoreCase) >= 0 // StringComparison.OrdinalIgnoreCase, ignores using toUpper or toLower. Words treated as equals.
|| blog[1].IndexOf(searchWord, StringComparison.OrdinalIgnoreCase) >= 0) // || - if true and true, if both are true.
{
// searches for wordmatch in both title and text
Console.WriteLine("Title: " + blog[0] + "\nText: " + blog[1] + "\n-------------------------"); // Writes out title and text with a seperation
search = true;
}

}
if (!search) // if searchword does not exist in vectorList
{
Console.WriteLine("Your search has failed!" + "\nNo blog exists with either character: " + searchWord.Substring(0));
}
break;
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Alright, back for some feedback and checks
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Alright, I can't figure this out.. So, this is what I have so far. Trying to give alternative options based on the first character of user input, if no post exists with the input of the user
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Alright, it's not done
188 replies
CC#
Created by Joriku on 5/7/2023 in #help
❔ Simple blog page (Homework)
Yeah, it's all sorted for now. Thank you!
188 replies