❔ Using the DateTime.Now

How do I apply a date for each blog that should have a publication date? https://gist.github.com/Programmer-Faraj/fdc814033943b69af8bdf19a00b83b14
Gist
This is an assignment project from my course
This is an assignment project from my course . GitHub Gist: instantly share code, notes, and snippets.
49 Replies
Omnissiah
Omnissiah2y ago
as a first thing, instead of having all those comments i would use methods and for example instead of switch case 1 case 2 etc at least i would put constants because 1 and 2 i don't know what they are this could be reflected in the menu too, like you could have 1 to save, but you could also write save to have a date for the post you should use a data structure like a class instead of string[] so that you have fields for title, post, and publicated (your date)
The king of kings
Thanks a lot for showing up to offer some help! I reviewed what you just mentioned and these tips are very useful for a clean and more readable code. if you read here you'll get an idea why I did it like this https://discord.com/channels/143867839282020352/169726586931773440/1099652430557356072
MODiX
MODiX2y ago
Faraj#6089
Guys, I couldn't figure out any solution for this issue. I'm trying store a date generated from
DateTime.Now
DateTime.Now
into my string list, but it seems like the list should be type
DateTime.Now
DateTime.Now
https://gist.github.com/Programmer-Faraj/fdc814033943b69af8bdf19a00b83b14
Embed Type
Article
Quoted by
<@!973964186956726313> from #help-0 (click here)
From Faraj#6089
React with ❌ to remove this embed.
The king of kings
I can't use a class but I could use methods
Omnissiah
Omnissiah2y ago
uhm i don't know what would be the part that says you might not use a class or in general data structures
The king of kings
Yeah! I don't know either. • May I build the structure of the blog around a list containing a class? No. It may be a "better" structure, as it gives more control, but that is not how the task goes out on. You must follow the given structure. _ this is what they say too
Omnissiah
Omnissiah2y ago
the given structure would be the swedish images or something else
The king of kings
which image one do you mean?
Omnissiah
Omnissiah2y ago
the "requirements"
The king of kings
Aha! Sorry, now I get what you mean. Let me show you their original structure, it's in Swedish, but I could translate it.
Basic functionality (E level)

To achieve E level, your program needs to be written with a consistent coding style and clear naming and contain the following

The blog should be a list that can save string vectors. Each individual blog post should be a string vector. The vectors must contain at least two elements. NOTE: You may not replace the vector list with a class. For more info see "Frequently Asked Questions - The Blog.pdf"
A working menu with choices for the program's functionality, use SWITCH.
Measures to prevent runtime errors.
Possibility to print posts from the blog.
Possibility to save new posts in the blog, with at least title and message.
Possibility to search for posts in the blog, for example by the title of the post. Use pseudocode or flowchart to plan the logic of the search. Start from a linear search in the coursebook. See chapter 14.2
Your search should be based on a comparison between a keyword and each post's title. Other forms of searches may be included as options, or to demonstrate that you can handle more advanced tools, but there must be a basic search that compares each post's title to a keyword.
Well-commented code that explains and justifies choices of data types, control structures, methods, data structures, and algorithms.

Extended functionality (C to A level)
When you are done with basic functionality, for C level or higher you can further develop the program complexity.. Note that C level requires both pseudocode and activity diagram in the planning stage.
Ability to save dates for logs. See the C# fundamentals material for how to work with dates.
Ability to edit and/or delete logs.
Create one or more methods for your program.
Working with Binary Search (A Level)
Implement a sorting algorithm for your program (A level)
Basic functionality (E level)

To achieve E level, your program needs to be written with a consistent coding style and clear naming and contain the following

The blog should be a list that can save string vectors. Each individual blog post should be a string vector. The vectors must contain at least two elements. NOTE: You may not replace the vector list with a class. For more info see "Frequently Asked Questions - The Blog.pdf"
A working menu with choices for the program's functionality, use SWITCH.
Measures to prevent runtime errors.
Possibility to print posts from the blog.
Possibility to save new posts in the blog, with at least title and message.
Possibility to search for posts in the blog, for example by the title of the post. Use pseudocode or flowchart to plan the logic of the search. Start from a linear search in the coursebook. See chapter 14.2
Your search should be based on a comparison between a keyword and each post's title. Other forms of searches may be included as options, or to demonstrate that you can handle more advanced tools, but there must be a basic search that compares each post's title to a keyword.
Well-commented code that explains and justifies choices of data types, control structures, methods, data structures, and algorithms.

Extended functionality (C to A level)
When you are done with basic functionality, for C level or higher you can further develop the program complexity.. Note that C level requires both pseudocode and activity diagram in the planning stage.
Ability to save dates for logs. See the C# fundamentals material for how to work with dates.
Ability to edit and/or delete logs.
Create one or more methods for your program.
Working with Binary Search (A Level)
Implement a sorting algorithm for your program (A level)
this is the whole assignment, but you can see at the bottom where it says the Extended functionality this is what we're dealing with right now
Omnissiah
Omnissiah2y ago
aaaah ok
The king of kings
I hope got a glimpse of the requirements
Omnissiah
Omnissiah2y ago
i would say this is not well formulated but ok i would not convert date to string i would rather keep two synchronized lists again, this from not having read ⚠️ the faq pdf ⚠️
The king of kings
Really! You mean the structure? neither we can I don't really know how the hell I would convert in this context, otherwise converting is so easy, but not here.
Omnissiah
Omnissiah2y ago
so, then?
The king of kings
faq pdf 🤔 are we able to convert in this context?
Omnissiah
Omnissiah2y ago
i'm not sure i'm following you still mean convert as convert datetime to string? but why?
The king of kings
Sorry, I said wrong, I've had bad sleep last night. The error says you can't convert DateTime. System to string, that means we can't.
Omnissiah
Omnissiah2y ago
so you don't want to have two lists one with the posts and one with the date
The king of kings
We could do that of course my friend, I tried it and it works. But here is the issue, the posts will be saved in the string list, and our date will be in a separated list, how am I able to combine the two with each other?
The king of kings
do you get what I mean logically?
Omnissiah
Omnissiah2y ago
items would have the same index in both lists that's why i used the word synchronized so post 1 data would have title and content in index 1 in first list and date in index 1 in second list
The king of kings
Ok! Wow, you're awesome man. You have a pretty good deep knowledge. I didn't know that. Happy to learn a new concept everyday 😀 so this is meant by synchronized I will add what you mentioned in my notes
Omnissiah
Omnissiah2y ago
that's not deep knowledge 😒
The king of kings
Really, for me it looks like it at least 😇 that's why they included this in the image with the assignment. so I go and implement that
The king of kings
what am I doing wrong here?
Omnissiah
Omnissiah2y ago
why are you using an array of DateTime inside a list
The king of kings
why I get System.DateTime[] all the time you're right, it has no meaning what so ever.
phaseshift
phaseshift2y ago
you need to use an individual instance of DateTime (.ToString) to get something meaningful
The king of kings
Bingo
The king of kings
It's working now 💪 I haven't practiced DateTime that much that's why I get stuck
phaseshift
phaseshift2y ago
its not special aboutDateTime, its a general rule array/list/dict etc wont automatically print 'nicely'
The king of kings
could you show me one example of what you mentioned? Ok
Omnissiah
Omnissiah2y ago
you could shorten stuff like List<DateTime> dateList = new List<DateTime>(); to var dateList = new List<DateTime>(); or List<DateTime> dateList = new() it doesn't seem you are using visual studio, i don't know if this has helpers for string formatting if you did a datetime_variable.ToString("") when the cursor is inside the "" a popup with the formatting tokens would appear
The king of kings
Yep, that's right. bro. The reason why I'm still weak in the c# fundamentals is because I'm using VS (Preview) version on MacBook Air and it has no feature literally nothing. I'm thinking about purchasing Rider instead, since I waste a ton of times in this dame VS I would purchase Rider so I could do like debug or use other features and save a ton of time does it make sense what I just mentioned for you? I find myself suck so often in the fundamentals because of my dame VS
Omnissiah
Omnissiah2y ago
not really if paradoxically you did everything in notepad this would force you to learn more stuff because there would be no automations still, a good ide to work with is obviously more productive
The king of kings
Oh! Really. So I was wrong in thinking about purchasing Rider. You're right. It makes sense. I guess I waste a lot of time, but at least I'm learning how to solve problems on my own without any automations like you mentioned.
Omnissiah
Omnissiah2y ago
i mean i don't know why you think vs is bad
The king of kings
it's bad in Mac because I can't debug or other features is notepad considered as an IDE too?
Omnissiah
Omnissiah2y ago
well ok vs on mac is not great but vs, albeit beng microsoft oriented, has useful features it's not
The king of kings
Really like what features? Oh! I thought so.
Omnissiah
Omnissiah2y ago
from the basics features like autocompletion and colorizing, plugins, refactoring (ok in rider it's probably better working), to eventually more advanced stuff like diagrams, performance diagnostics, ia for autocompletion, the visual part if you use forms and such, task list if you use it, and so on
The king of kings
Wow, you have a good enough knowledge in the IDEs how do you know all that? Are you a senior developer or sort of? Or maybe you've used both editors and gained some knowledge a long the way. man I got stuck again and I have submit my assignment today, because I'm out of the deadline.
Omnissiah
Omnissiah2y ago
mine was still a generic argument, this is a little more onpoint but still not in depth https://visualstudio.microsoft.com/vs/compare/ one of the features i like a lot is the remote debugger
Visual Studio
Compare Visual Studio Product Offerings | Visual Studio
Compare Visual Studio 2022 offerings to find the set of tools & resources that's best for you.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
The king of kings
Not yet @dontHey man, are you available?
Omnissiah
Omnissiah2y ago
i was at the notary and now i have to go to work
The king of kings
Aha! Ok! It's totally alright man. Thanks a lot though 😃
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server