你写一个图书管理系统系统,这个系统在vs中用c#语言写后端代码,在vsCode中用vue写前端代码

时间: 2023-11-28 12:49:28 浏览: 38
好的,下面是一个简单的图书管理系统的后端代码示例,使用C#语言编写,可以在Visual Studio中运行: ``` using System; using System.Collections.Generic; namespace BookManagementSystem { class Program { static List<Book> bookList = new List<Book>(); static void Main(string[] args) { Console.WriteLine("Welcome to the Book Management System!"); while (true) { Console.WriteLine("1. Add a book"); Console.WriteLine("2. Search for a book"); Console.WriteLine("3. View all books"); Console.WriteLine("4. Exit"); int choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: AddBook(); break; case 2: SearchBook(); break; case 3: ViewAllBooks(); break; case 4: Environment.Exit(0); break; default: Console.WriteLine("Invalid choice!"); break; } } } static void AddBook() { Console.WriteLine("Enter book title:"); string title = Console.ReadLine(); Console.WriteLine("Enter author name:"); string author = Console.ReadLine(); Console.WriteLine("Enter publication year:"); int year = int.Parse(Console.ReadLine()); Book book = new Book(title, author, year); bookList.Add(book); Console.WriteLine("Book added successfully!"); } static void SearchBook() { Console.WriteLine("Enter book title:"); string title = Console.ReadLine(); foreach (Book book in bookList) { if (book.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Book found:"); Console.WriteLine(book); return; } } Console.WriteLine("Book not found!"); } static void ViewAllBooks() { foreach (Book book in bookList) { Console.WriteLine(book); } } } class Book { public string Title { get; set; } public string Author { get; set; } public int Year { get; set; } public Book(string title, string author, int year) { Title = title; Author = author; Year = year; } public override string ToString() { return Title + " by " + Author + " (" + Year + ")"; } } } ``` 下面是一个简单的图书管理系统的前端代码示例,使用Vue.js编写,可以在VS Code中运行: ``` <template> <div> <h1>Book Management System</h1> <form @submit.prevent="addBook"> <label for="title">Title:</label> <input type="text" id="title" v-model="newBook.title" required> <br> <label for="author">Author:</label> <input type="text" id="author" v-model="newBook.author" required> <br> <label for="year">Publication Year:</label> <input type="number" id="year" v-model.number="newBook.year" required> <br> <button>Add Book</button> </form> <hr> <h2>Search for a Book</h2> <form @submit.prevent="searchBook"> <label for="searchTitle">Title:</label> <input type="text" id="searchTitle" v-model="searchTitle" required> <br> <button>Search</button> </form> <hr> <h2>All Books</h2> <ul> <li v-for="book in bookList">{{ book.title }} by {{ book.author }} ({{ book.year }})</li> </ul> </div> </template> <script> export default { data() { return { newBook: { title: "", author: "", year: 0 }, searchTitle: "", bookList: [] }; }, methods: { addBook() { this.bookList.push({ title: this.newBook.title, author: this.newBook.author, year: this.newBook.year }); this.newBook.title = ""; this.newBook.author = ""; this.newBook.year = 0; }, searchBook() { for (let i = 0; i < this.bookList.length; i++) { if (this.bookList[i].title.toLowerCase() === this.searchTitle.toLowerCase()) { alert(this.bookList[i].title + " by " + this.bookList[i].author + " (" + this.bookList[i].year + ")"); return; } } alert("Book not found!"); } } }; </script> ```

相关推荐

最新推荐

recommend-type

详解vscode中vue代码颜色插件

vscode的确是前端开发中很好的工具,安装颜色插件,从视觉上是美的享受。这篇文章主要介绍了vscode中vue代码颜色插件 ,需要的朋友可以参考下
recommend-type

基于vue写一个全局Message组件的实现

主要介绍了基于vue写一个全局Message组件的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

vue实现后台管理权限系统及顶栏三级菜单显示功能

主要介绍了vue实现后台管理权限系统及顶栏三级菜单显示功能,本文图文并茂给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
recommend-type

vue中如何实现后台管理系统的权限控制的方法步骤

主要介绍了vue中如何实现后台管理系统的权限控制的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

在vue项目中使用codemirror插件实现代码编辑器功能

主要介绍了在vue项目中使用codemirror插件实现代码编辑器功能(代码高亮显示及自动提示),本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解释minorization-maximization (MM) algorithm,并给出matlab代码编写的例子

Minorization-maximization (MM) algorithm是一种常用的优化算法,用于求解非凸问题或含有约束的优化问题。该算法的基本思想是通过构造一个凸下界函数来逼近原问题,然后通过求解凸下界函数的最优解来逼近原问题的最优解。具体步骤如下: 1. 初始化参数 $\theta_0$,设 $k=0$; 2. 构造一个凸下界函数 $Q(\theta|\theta_k)$,使其满足 $Q(\theta_k|\theta_k)=f(\theta_k)$; 3. 求解 $Q(\theta|\theta_k)$ 的最优值 $\theta_{k+1}=\arg\min_\theta Q(
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。