Skip to content
Snippets Groups Projects
Commit fd09bd44 authored by Joonas Seppä's avatar Joonas Seppä
Browse files

Publishing the project

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 202 additions and 0 deletions
Book.cs 0 → 100644
namespace Books{
//Book object, that has properties name, author and pages, and a method to check if book is long
class Book{
public string name;
public string author;
public int pages;
public Book(string aName, string aAuthor, int aPages){
name = aName;
author = aAuthor;
pages = aPages;
}
//Checks if the book is longer than 500 pages and prints out the result
public void isLong(){
if(pages > 500){
Console.WriteLine("Book: " + name + " is a long book!");
}
else{
Console.WriteLine(name + " is a short book!");
}
}
}
}
\ No newline at end of file
using Books;
class Program{
static void Main(string[] args){
Book[] aList = createBooks();
infoOfBooks(aList);
}
//Creates books in CLI, returns list of created books
static Book[] createBooks(){
Console.Write("How many books do you want to create?: ");
int amountOfBooks = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Book[] bookList = new Book[amountOfBooks];
for(int i=0; i<amountOfBooks; i++){
Console.Write("Enter the name of the book: ");
string name = Console.ReadLine();
Console.Write("Enter the author of the book: ");
string author = Console.ReadLine();
Console.Write("Enter the amount of pages in the book: ");
int pages = Convert.ToInt32(Console.ReadLine());
bookList[i] = new Book(name, author, pages);
Console.WriteLine();
}
return bookList;
}
//Displays info of books
static void infoOfBooks(Book[] list){
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
int length = list.Length;
Console.WriteLine("You have " + list.Length + " books!");
Console.WriteLine();
for(int i=0;i<length;i++){
Console.WriteLine("Name: " + list[i].name);
Console.WriteLine("Author: " + list[i].author);
Console.WriteLine("Pages: " + list[i].pages);
list[i].isLong();
Console.WriteLine();
}
}
}
This is my first C# application.
It uses CLI to ask the user book information, and creates a list of books based on that.
Finally it delivers information of the given books back to the user.
The runnable file is bin/Debug/net7.0/publish/secondApp
That file is written in intermediate language (IL) and requires Common Language Runtime (CLR) to be run. As such it should be runnable on any standard operating system.
Alternatively the program can also be run with dotnet using "dotnet run" on the program's root directory.
\ No newline at end of file
File added
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"secondApp/1.0.0": {
"runtime": {
"secondApp.dll": {}
}
}
}
},
"libraries": {
"secondApp/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
File added
File added
{
"runtimeOptions": {
"tfm": "net7.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "7.0.0"
}
}
}
\ No newline at end of file
File added
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"secondApp/1.0.0": {
"runtime": {
"secondApp.dll": {}
}
}
}
},
"libraries": {
"secondApp/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
File added
File added
{
"runtimeOptions": {
"tfm": "net7.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "7.0.0"
}
}
}
\ No newline at end of file
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
/Users/joonasseppa/Desktop/training/cSharpTraining/secondApp/bin/Debug/net7.0/publish/secondApp
/Users/joonasseppa/Desktop/training/cSharpTraining/secondApp/bin/Debug/net7.0/publish/secondApp.dll
/Users/joonasseppa/Desktop/training/cSharpTraining/secondApp/bin/Debug/net7.0/publish/secondApp.deps.json
/Users/joonasseppa/Desktop/training/cSharpTraining/secondApp/bin/Debug/net7.0/publish/secondApp.runtimeconfig.json
/Users/joonasseppa/Desktop/training/cSharpTraining/secondApp/bin/Debug/net7.0/publish/secondApp.pdb
File added
File added
File added
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("secondApp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("secondApp")]
[assembly: System.Reflection.AssemblyTitleAttribute("secondApp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
d0107aa9b08376622df81e28f7d95211d3729287
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment