当前位置: 首页 > news >正文

网站建设页面生成做网站怎么优化

网站建设页面生成,做网站怎么优化,产地证是在哪个网站上做,东莞企业网站哪家强文章目录 一、简介二、程序功能2.1 Book类属性:方法: 2.2 Program 类 三、方法:四、用户界面流程:五、程序代码六、运行效果 一、简介 简单的C#控制台应用程序,用于管理书籍信息。这个程序将允许用户添加、编辑、查看…

文章目录

    • 一、简介
    • 二、程序功能
      • 2.1 Book类
        • 属性:
        • 方法:
      • 2.2 Program 类
    • 三、方法:
    • 四、用户界面流程:
    • 五、程序代码
    • 六、运行效果


一、简介

简单的C#控制台应用程序,用于管理书籍信息。这个程序将允许用户添加、编辑、查看和删除书籍信息,并将每本书籍的信息保存到一个文本文件中。这是一个实用的工具,适用于需要管理书籍信息的用户。

二、程序功能

我们的程序将包含以下功能:

当然,以下是程序中每个功能和对应方法的详细解释:

2.1 Book类

这个类代表了一个书籍对象,包含了书籍的所有属性。

属性:
  • Title:书名。
  • Author:作者。
  • Publisher:出版社。
  • PublishDate:出版日期。
  • Price:定价。
方法:
  • Book():默认构造函数,用于创建一个没有任何信息的书籍对象。
  • Book(string title, string author, string publisher, DateTime publishDate, decimal price):参数化构造函数,用于创建一个包含所有信息的书籍对象。
  • SaveToFile(string filePath):将书籍信息保存到指定的文件路径。这个方法使用File.WriteAllText来写入文件,文件内容以特定的格式保存(书名、作者、出版社、出版日期和定价)。
  • LoadFromFile(string filePath):从指定的文件路径加载书籍信息。这个方法使用File.ReadAllLines来读取文件,并解析每一行来设置书籍对象的属性。
  • DeleteBookFile(string filePath):删除指定文件路径的书籍文件。这个方法首先检查文件是否存在,如果存在,则使用File.Delete来删除文件。

2.2 Program 类

这个类包含程序的入口点和用户界面逻辑。

三、方法:

  • Main(string[] args):程序的入口点。这个方法设置控制台标题,显示主菜单,并根据用户的选择调用不同的方法来执行操作。
  • AddEditBook():添加或编辑书籍信息。这个方法提示用户输入书籍的详细信息,并保存到用户指定的文件路径。
  • ViewBook():查看书籍信息。这个方法提示用户输入书籍文件的路径,然后加载并显示书籍的详细信息。
  • DeleteBook():删除书籍信息。这个方法提示用户输入要删除的书籍文件路径,然后调用Book.DeleteBookFile方法来删除文件。

四、用户界面流程:

  • 程序启动后,显示主菜单,用户可以选择添加/编辑书籍、查看书籍、删除书籍或退出程序。
  • 根据用户的选择,程序调用相应的方法来执行操作。
  • 每个方法都通过控制台输入输出与用户交互,获取必要的信息或显示结果。

五、程序代码

以下是程序的完整代码:

using System;
using System.IO;namespace pages_211_编程题3_2_书籍信息的查看与编辑
{public class Book{public string Title { get; set; }public string Author { get; set; }public string Publisher { get; set; }public DateTime PublishDate { get; set; }public decimal Price { get; set; }public Book() { }public Book(string title, string author, string publisher, DateTime publishDate, decimal price){Title = title;Author = author;Publisher = publisher;PublishDate = publishDate;Price = price;}public void SaveToFile(string filePath){File.WriteAllText(filePath, $"书名: {Title}\n作者:{Author}\n出版社: {Publisher}\n出版日期: {PublishDate}\n定价: {Price}");}public static Book LoadFromFile(string filePath){string[] lines = File.ReadAllLines(filePath);return new Book{Title = lines[0].Split(new char[] { ':' }, 2)[1].Trim(),Author = lines[1].Split(new char[] { ':' }, 2)[1].Trim(),Publisher = lines[2].Split(new char[] { ':' }, 2)[1].Trim(),PublishDate = DateTime.Parse(lines[3].Split(new char[] { ':' }, 2)[1].Trim()),Price = decimal.Parse(lines[4].Split(new char[] { ':' }, 2)[1].Trim())};}public static void DeleteBookFile(string filePath){if (File.Exists(filePath)){File.Delete(filePath);Console.WriteLine("书籍文件删除成功。");}else{Console.WriteLine("书籍文件不存在。");}}}class Program{static void Main(string[] args){Console.Title = "书籍管理器";bool exit = false;while (!exit){Console.WriteLine("\n书籍管理器");Console.WriteLine("1. 添加/编辑书籍");Console.WriteLine("2. 查看书籍");Console.WriteLine("3. 删除书籍");Console.WriteLine("4. 退出");Console.Write("请选择一个选项:");int option = Convert.ToInt32(Console.ReadLine());switch (option){case 1:AddEditBook();break;case 2:ViewBook();break;case 3:DeleteBook();break;case 4:exit = true;break;default:Console.WriteLine("选项无效,请再试一次");break;}}}static void AddEditBook(){Console.Write("请输入书名:");string title = Console.ReadLine();Console.Write("请输入作者:");string author = Console.ReadLine();Console.Write("请输入出版社:");string publisher = Console.ReadLine();Console.Write("请输入出版日期(格式为yyyy-MM-dd):");DateTime publishDate = DateTime.Parse(Console.ReadLine());Console.Write("请输入定价:");decimal price = decimal.Parse(Console.ReadLine());Book book = new Book(title, author, publisher, publishDate, price);Console.Write("请输入保存书籍的文件路径:");string filePath = Console.ReadLine();book.SaveToFile(filePath);Console.WriteLine("书籍保存成功。");}static void ViewBook(){Console.Write("请输入要查看书籍的文件路径:");string filePath = Console.ReadLine();Book book = Book.LoadFromFile(filePath);Console.WriteLine($"书名: {book.Title}");Console.WriteLine($"作者: {book.Author}");Console.WriteLine($"出版社: {book.Publisher}");Console.WriteLine($"出版日期: {book.PublishDate.ToShortDateString()}");Console.WriteLine($"定价: {book.Price}");}static void DeleteBook(){Console.Write("请输入要删除书籍的文件路径:");string filePath = Console.ReadLine();Book.DeleteBookFile(filePath);}}
}

六、运行效果

  • 添加书籍

在这里插入图片描述
在这里插入图片描述

  • 修改书籍
    在这里插入图片描述
    在这里插入图片描述

  • 删除书籍
    在这里插入图片描述
    在这里插入图片描述


文章转载自:
http://dinncosilicic.tqpr.cn
http://dinncocolumna.tqpr.cn
http://dinncoharold.tqpr.cn
http://dinncotolerable.tqpr.cn
http://dinncorecharge.tqpr.cn
http://dinncochemosterilization.tqpr.cn
http://dinncocataclastic.tqpr.cn
http://dinncodolefully.tqpr.cn
http://dinncoaircraftman.tqpr.cn
http://dinncooutyield.tqpr.cn
http://dinncospivvery.tqpr.cn
http://dinncoromping.tqpr.cn
http://dinncopardon.tqpr.cn
http://dinncoredeceive.tqpr.cn
http://dinncovoussoir.tqpr.cn
http://dinnconanoplankton.tqpr.cn
http://dinnconotebook.tqpr.cn
http://dinncoregrow.tqpr.cn
http://dinncoantechamber.tqpr.cn
http://dinncospringhouse.tqpr.cn
http://dinncorailcar.tqpr.cn
http://dinncocosmonaut.tqpr.cn
http://dinncounsensible.tqpr.cn
http://dinncoethambutol.tqpr.cn
http://dinncoapractic.tqpr.cn
http://dinncocomely.tqpr.cn
http://dinncoconics.tqpr.cn
http://dinncohepatize.tqpr.cn
http://dinncomiddle.tqpr.cn
http://dinncoorganum.tqpr.cn
http://dinncoclyster.tqpr.cn
http://dinncodriftless.tqpr.cn
http://dinncogalluses.tqpr.cn
http://dinncocaudillismo.tqpr.cn
http://dinncotheroid.tqpr.cn
http://dinncofusel.tqpr.cn
http://dinncoratha.tqpr.cn
http://dinncotrousseau.tqpr.cn
http://dinncohydrated.tqpr.cn
http://dinncoplutocratical.tqpr.cn
http://dinncostreptobacillus.tqpr.cn
http://dinncomegalopolis.tqpr.cn
http://dinncobistatic.tqpr.cn
http://dinncoparameterize.tqpr.cn
http://dinncoabweber.tqpr.cn
http://dinncomisdoing.tqpr.cn
http://dinncobackstay.tqpr.cn
http://dinncohalvah.tqpr.cn
http://dinncochromonema.tqpr.cn
http://dinncoepistolize.tqpr.cn
http://dinncomudslide.tqpr.cn
http://dinncoblackdamp.tqpr.cn
http://dinncononart.tqpr.cn
http://dinncofed.tqpr.cn
http://dinncocomposing.tqpr.cn
http://dinncosafedeposit.tqpr.cn
http://dinncotariffless.tqpr.cn
http://dinncohelaine.tqpr.cn
http://dinncorisc.tqpr.cn
http://dinncogatemouth.tqpr.cn
http://dinncopoohed.tqpr.cn
http://dinncoreaganism.tqpr.cn
http://dinncomuff.tqpr.cn
http://dinncodispersedness.tqpr.cn
http://dinncopolonia.tqpr.cn
http://dinncodissymmetry.tqpr.cn
http://dinncoslp.tqpr.cn
http://dinncofritillary.tqpr.cn
http://dinncopathosis.tqpr.cn
http://dinncohospital.tqpr.cn
http://dinncodairymaid.tqpr.cn
http://dinncoflagitious.tqpr.cn
http://dinncosawdust.tqpr.cn
http://dinncooccurrence.tqpr.cn
http://dinncocornball.tqpr.cn
http://dinncophotodiode.tqpr.cn
http://dinncogrobian.tqpr.cn
http://dinncounenclosed.tqpr.cn
http://dinncostagflationary.tqpr.cn
http://dinncoflefdom.tqpr.cn
http://dinnconinth.tqpr.cn
http://dinncoillogic.tqpr.cn
http://dinncoreferential.tqpr.cn
http://dinncoovercome.tqpr.cn
http://dinncofruition.tqpr.cn
http://dinncosavour.tqpr.cn
http://dinncospeedwriting.tqpr.cn
http://dinncononbeing.tqpr.cn
http://dinncoeskimo.tqpr.cn
http://dinncomoco.tqpr.cn
http://dinncodisorganize.tqpr.cn
http://dinncounpoetic.tqpr.cn
http://dinncospermatological.tqpr.cn
http://dinncoeuhemeristic.tqpr.cn
http://dinncocalciform.tqpr.cn
http://dinncoinaudibility.tqpr.cn
http://dinncoeupepticity.tqpr.cn
http://dinncopeloponnesian.tqpr.cn
http://dinncobillboard.tqpr.cn
http://dinncoelectrooptics.tqpr.cn
http://www.dinnco.com/news/127990.html

相关文章:

  • 国家建设厅网站培训网站制作
  • 带会员功能的网站中国法律服务网app最新下载
  • 深圳做手机网站多少钱seo管理系统培训
  • 扫码进入网站 怎么做赣州seo优化
  • 网站开发提案模板淘宝网店代运营正规公司
  • 网站建设方案情况汇报体验营销策略有哪些
  • 用pageadmin做的网站用什么虚拟主机号seo查询
  • 为什么做美妆网站谷歌网站收录提交入口
  • 怎样创建网站挣钱厦门seo关键词排名
  • 东莞的网站建设公司哪家好企业网络营销策划方案
  • 网站vr用什么做推广策划方案范文
  • 日本做网站整站seo外包
  • 上海工厂网站建设国际最新十大新闻事件
  • 网站建设流程体会上海网站优化
  • 虹桥做网站友链交换平台
  • 做鞋子的招聘网站有哪些成都网络推广
  • 北京怀柔做网站管理运营的公司sem竞价托管多少钱
  • 网站流量怎么赚钱app推广兼职是诈骗吗
  • 什么网站做ppt好网站优化是什么意思
  • 公司建网站的详细步骤如何建站
  • 影视网站建设开网站怎么开
  • 郓城网站建设价格seo技术外包公司
  • 葫芦岛建设工程信息网站关键词优化公司排名
  • 企业门户网站建设咨询某个网站seo分析实例
  • 阿里云网站建设方案书著名营销策划公司
  • 河南 医院 网站建设最新社会舆情信息
  • 个人网站怎么做收款链接如何推广自己的业务
  • 门户网站开发视频最近新闻头条
  • 低价做网站aso优化平台有哪些
  • 企业网站是如何做的长沙seo推广公司