您的位置:首页 > 游戏 > 手游 > 中国十大装修公司_html网页制作代码大全示范_百度搜索官网_免费自制app软件

中国十大装修公司_html网页制作代码大全示范_百度搜索官网_免费自制app软件

2024/12/26 9:08:21 来源:https://blog.csdn.net/2403_87107889/article/details/143584923  浏览:    关键词:中国十大装修公司_html网页制作代码大全示范_百度搜索官网_免费自制app软件
中国十大装修公司_html网页制作代码大全示范_百度搜索官网_免费自制app软件

答案:BABCB

import java.awt.print.Book
import scala.collection.mutable.ListBuffer
//1
class Book(var bookName:String,var bookAuthor:String,var price:Double){}object p3 {def main(args: Array[String]): Unit = {val bookList = ListBuffer[Book]()//2bookList += new Book("书1","作者1",33)bookList += new Book("书2","作者2",22)bookList += new Book("书3","作者3",56)bookList += new Book("书4","作者4",76)bookList += new Book("书5","作者5",45)bookList += new Book("书6","作者6",78)println(bookList)//3bookList.prepend(new Book("书7","作者7",44.9))println(bookList)//4bookList.insert(2,new Book("书8","作者8",29.53))println(bookList)//5def bookExists(bookName: String, bookList: ListBuffer[Book]): Boolean = {for (book <- bookList) {if (book.bookName == bookName) {return true}}false}val exists = bookExists("书8", bookList)println(exists)//6bookList.remove(3)//7val sortedBooks = bookList.toList.sortBy(-_.price)//8sortedBooks.foreach(book => println(s"Title: ${book.bookName},Author: ${book.bookAuthor}, Price: ${book.price}"))}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com