练习练习练习
人机猜拳import java.util.Scanner;public class Qwe {public static void main(String[] args) {new Game().play();}}class User {private String name;private Scanner scanner new Scanner(System.in);private int choice;public User(String name) {this.name name;}public String getName() {return name;}public void game() {System.out.print(请出拳);choice scanner.nextInt();while (true) {if (choice 1) {System.out.println(你出拳剪刀);break;} else if (choice 2) {System.out.println(你出拳石头);break;} else if (choice 3) {System.out.println(你出拳布);break;} else {System.out.print(输入不合法请重新输入);choice scanner.nextInt();}}}public int getChoice() {return choice;}}class Computer {private int winCount;private int loseCount;private int total;private String fistName(int n) {if (n 1) return 剪刀;else if (n 2) return 石头;else return 布;}private int judge(int userChoice, int computerChoice) {if (userChoice computerChoice) return 0;if ((userChoice 1 computerChoice 3)|| (userChoice 2 computerChoice 1)|| (userChoice 3 computerChoice 2)) return 1;else return -1;}public void computerGame(User user, String role) {winCount 0;loseCount 0;total 0;Scanner scanner new Scanner(System.in);String again;do {total;user.game();int computerChoice (int) (Math.random() * 3) 1;System.out.println(role 出拳 fistName(computerChoice));int result judge(user.getChoice(), computerChoice);if (result 1) {System.out.println(恭喜你赢了);winCount;} else if (result -1) {System.out.println(很遗憾你输了);loseCount;} else {System.out.println(平局);}System.out.print(是否继续 y/n );again scanner.next();} while (y.equals(again));}public int getWinCount() { return winCount; }public int getLoseCount() { return loseCount; }public int getTotal() { return total; }}class Game {private Scanner scanner new Scanner(System.in);public void play() {System.out.println(******************************** 猜拳 ,开始 ********************************);System.out.println(出拳规则1.剪刀 2.石头 3.布);System.out.print(请输入你的名字);String userName scanner.next();User user new User(userName);String roundAgain;do {System.out.print(请选择对方的角色1.刘备 2.孙权 3.曹操);String role null;while (true) {int choice scanner.nextInt();if (choice 1) role 刘备;else if (choice 2) role 孙权;else if (choice 3) role 曹操;if (role ! null) {System.out.println(你选择了 role 对敌);break;}System.out.print(输入错误请重新输入);}System.out.print(要开始吗 y/n );String start scanner.next();if (!y.equals(start)) {System.out.println(已退出);break;}Computer computer new Computer();computer.computerGame(user, role);int userWin computer.getWinCount();int compWin computer.getLoseCount();int total computer.getTotal();if (userWin compWin) {System.out.println(userName VS role 比分为 userWin : compWin 对战场次 total 把 userName 胜利);} else if (compWin userWin) {System.out.println(userName VS role 比分为 userWin : compWin 对战场次 total 把 role 胜利);} else {System.out.println(userName VS role 比分为 userWin : compWin 对战场次 total 把平局);}System.out.print(是否开启下一轮 y/n );roundAgain scanner.next();} while (y.equals(roundAgain));System.out.println(游戏结束);}}怪物模块class Monster {String name;int blood;int attackPower;int defence;public void attack() { System.out.println(攻击); }public void move() { System.out.println(移动); }}class Goblin extends Monster {int rage;Overridepublic void attack() {System.out.println(哥布林正在用石头攻击);}Overridepublic void move() {System.out.println(哥布林缓慢移动);}}class CatDemon extends Monster {Overridepublic void attack() {System.out.println(猫妖正在用爪子攻击你);}Overridepublic void move() {System.out.println(猫妖跳着移动);}}抽象绘制abstract class All {String x;String y;String color;public abstract void draw();}class Line extends All {String finalCoordinate;String originalCoordinate;Overridepublic void draw() { System.out.println(绘制线条); }}class Rectangle extends All {int length;int width;Overridepublic void draw() { System.out.println(绘制矩形); }}class Circle extends All {int r;Overridepublic void draw() { System.out.println(绘制圆形); }}class Test1 {static public void testpage() {All[] a new All[3];a[0] new Line();a[1] new Circle();a[2] new Rectangle();for (int i 0; i a.length; i) {a[i].draw();}}}员工管理abstract class All {String x;String y;String color;public abstract void draw();}class Line extends All {String finalCoordinate;String originalCoordinate;Overridepublic void draw() { System.out.println(绘制线条); }}class Rectangle extends All {int length;int width;Overridepublic void draw() { System.out.println(绘制矩形); }}class Circle extends All {int r;Overridepublic void draw() { System.out.println(绘制圆形); }}class Test1 {static public void testpage() {All[] a new All[3];a[0] new Line();a[1] new Circle();a[2] new Rectangle();for (int i 0; i a.length; i) {a[i].draw();}}}Employees[] employees new Employees[100];for (int i 0; i employees.length; i) {if (Math.random() 0.5) {employees[i] new Manager();} else {employees[i] new Coder();}}for (Employees e : employees) {e.work();}面积形状class Shape {public double area() { return 0; }public void show() { System.out.println(这是一个形状); }}class Circles extends Shape {double radius;public Circles(double radius) { this.radius radius; }Overridepublic double area() { return Math.PI * radius * radius; }Overridepublic void show() { System.out.println(这是一个圆形); }}class Rectangles extends Shape {double length;double width;public Rectangles(double length, double width) {this.length length;this.width width;}Overridepublic void show() { System.out.println(这是一个矩形); }Overridepublic double area() { return length * width; }}class Test2 {static public void test2() {Scanner scanner new Scanner(System.in);System.out.println(请输入半径);double r scanner.nextDouble();System.out.println(请输入长和宽);double a scanner.nextDouble();double b scanner.nextDouble();Shape[] shape new Shape[2];shape[0] new Circles(r);shape[1] new Rectangles(a, b);for (int i 0; i shape.length; i) {System.out.println(shape[i].area());shape[i].show();}}}数组扩容class M {static public void array() {int i 0;Scanner scanner new Scanner(System.in);int[] arr new int[2];System.out.println(请输入数字-1结束);while (true) {int b scanner.nextInt();if (b -1) {System.out.println(结束输入);break;}arr[i] b;i;if (i arr.length) {arr Arrays.copyOf(arr, arr.length * 2);}}// 只打印有效部分for (int j 0; j i; j) {System.out.print(arr[j] );}}}学生管理class Student {private String name;private int age;private int score;public Student(int age, String name, int score) {this.age age;this.name name;if (score 0 || score 100) {System.out.println(成绩不合法);} else {this.score score;}}public int getAge() { return age; }public String getName() { return name; }public int getScore() { return score; }public void setAge(int age) { this.age age; }public void setName(String name) { this.name name; }public void setScore(int score) {if (score 0 || score 100) {System.out.println(成绩不合法);} else {this.score score;}}public void show() {System.out.println(姓名 name 年龄 age 成绩 score);}}

相关新闻

Flask构建残障社区服务平台的技术实践

Flask构建残障社区服务平台的技术实践

1. 项目背景与核心需求社区残障人士服务平台的开发源于一个普遍存在却常被忽视的社会痛点——残障群体在获取社区服务时面临的信息不对称和物理障碍。传统服务模式往往需要残障人士主动到指定地点登记需求,这种"被动等待"的服务机制对行动不便者极不友好。…

2026/10/2 1:44:24 阅读更多 →
11. 类和动态内存分配

11. 类和动态内存分配

类和动态内存分配动态内存和类在类中使用 new 和 delete 来动态管理内存,可以让程序在运行时(而非编译时)决定内存分配。在类构造函数中使用 new,需要额外执行一系列步骤:扩展析构函数、编写额外的类方法来帮助正确完成…

2026/9/23 2:07:41 阅读更多 →
高职统计与大数据分析专业现状与就业前景

高职统计与大数据分析专业现状与就业前景

1. 统计与大数据分析专业现状解析统计与大数据分析作为新兴交叉学科,近年来在高职院校的专业设置中呈现出明显的上升趋势。从行业需求端来看,2023年人社部发布的《新职业在线学习平台发展报告》显示,数据分析师岗位缺口已达150万人&#xff0…

2026/10/2 14:45:00 阅读更多 →

最新新闻

TerraScan点云处理实战:参数原理与LiDAR测绘精度控制

TerraScan点云处理实战:参数原理与LiDAR测绘精度控制

简介:本资源是一份面向测绘、遥感、地理信息系统(GIS)及三维建模领域从业者与高校相关专业师生的技术参考文献,系统讲解基于TerraScan软件的LiDAR点云数据处理全流程。内容涵盖LiDAR技术原理与发展现状、TerraScan核心功能&#x…

2026/10/2 22:51:07 阅读更多 →
HGRV轨迹预测:贝叶斯粒子滤波建模与Python实现

HGRV轨迹预测:贝叶斯粒子滤波建模与Python实现

简介:这是一份关于高超声速滑翔飞行器(HGRV)轨迹预测的完整复现资料,面向具备一定编程和数学基础、对贝叶斯推断与粒子滤波感兴趣的科研人员和工程师。资源以docx文档形式整理了论文复现思路与详细代码解释,覆盖意图代…

2026/10/2 22:51:07 阅读更多 →
LabVIEW数据存储指南:TDMS文件读写方案与性能优化

LabVIEW数据存储指南:TDMS文件读写方案与性能优化

先说结论:这套存储读写方案我在实验室里用了快四年,从单通道几十Hz的慢速采集,到八通道连续一周的疲劳试验,再到偶尔要回放分析的老数据,基本都覆盖到了。如果你正在用LabVIEW做数据采集、信号处理或者设备状态记录&am…

2026/10/2 22:51:07 阅读更多 →
URLLC短码长通信:突破香农极限的实时可靠传输

URLLC短码长通信:突破香农极限的实时可靠传输

1. 什么是URLLC场景下的短码长 regime?——从工厂产线到远程手术的真实需求倒逼出来的通信范式你有没有想过,为什么5G宣传里总说“一毫秒时延”,但实际用手机打视频电话,卡顿还是时有发生?问题不在基站功率&#xff0c…

2026/10/2 22:51:07 阅读更多 →
AI写作合规指南:守住作者性的技术边界

AI写作合规指南:守住作者性的技术边界

1. 事件本质与行业震动:一场关于“作者性”的边界测试 “Author Dropped from Literary Prize over AI Allegations”——这行标题不是一则娱乐八卦,而是一记敲在当代文学创作神经末梢上的重锤。它背后没有算法黑箱的神秘感,也没有技术厂商的…

2026/10/2 22:51:07 阅读更多 →
蛋白质功能位点识别平台构建:从数据到部署的机器学习全流程

蛋白质功能位点识别平台构建:从数据到部署的机器学习全流程

简介:这份PDF文献面向生物信息学、蛋白质功能研究方向的初学者与科研人员,系统讲解如何用支持向量机(SVM)构建蛋白质功能位点识别的通用机器学习平台。内容涵盖非同源序列提取、序列特征编码(基本信息、物化特征、结构…

2026/10/2 22:50:06 阅读更多 →

日新闻

从零搭建AI工程化:模型之外的完整闭环

从零搭建AI工程化:模型之外的完整闭环

先搞清楚一件事:从零开始做 AI 工程化,难的从来不是调模型、写提示词,而是把一套原型 Demo 变成长得像是“正经系统”的东西。你手里可能已经有了能跑通的代码,也可能刚读完一些概念,但真到了要把它变成可维护、可观测…

2026/10/2 0:00:20 阅读更多 →
大模型训练显存估计与混合精度训练实战指南

大模型训练显存估计与混合精度训练实战指南

1. 大模型训练显存估计与混合精度训练详解显存不够用,几乎是每个做大模型训练的人都会撞上的第一堵墙。你可能也经历过:模型代码写完了,数据管道跑通了,满心欢喜地按下训练启动脚本,结果几秒钟后终端弹出一行红字——C…

2026/10/2 0:00:20 阅读更多 →
小样本学习数据集选型指南:27个真正可用的高质量数据集

小样本学习数据集选型指南:27个真正可用的高质量数据集

1. 小样本学习的“弹药库”:为什么你总在找数据集,却总找不到真正能用的? 小样本、数据集——这两个词最近半年在我处理的200多个AI项目咨询里,出现频率排进前三。不是模型调不好,不是代码写不对,而是卡在…

2026/10/2 0:00:20 阅读更多 →

周新闻

如何划分训练/验证集:Spirula Studio五种eval_mode策略详解

如何划分训练/验证集:Spirula Studio五种eval_mode策略详解

如何划分训练/验证集:Spirula Studio五种eval_mode策略详解 【免费下载链接】spirula-studio Cross-vendor 3D Gaussian Splatting trainer - video to splat to mesh, Vulkan or CUDA. 项目地址: https://gitcode.com/GitHub_Trending/sp/spirula-studio Sp…

2026/10/1 19:40:48 阅读更多 →
SEO怎么推广速查手册新手避坑实战指南

SEO怎么推广速查手册新手避坑实战指南

SEO怎么推广速查手册新手避坑实战指南 模板网站太丑不够用?别急着加滤镜,那是治标不治本。很多老板盯着后台流量掉得眼红,却还在纠结首页Banner的圆角是不是3像素。这就像穿着西装去挖土,姿势不对,努力白费。我整理这份 速查手册…

2026/10/1 19:41:40 阅读更多 →
FireRed-OpenStoryline少样本仿写深度解析:AI Agent如何复刻你的独特文案风格与节奏

FireRed-OpenStoryline少样本仿写深度解析:AI Agent如何复刻你的独特文案风格与节奏

FireRed-OpenStoryline少样本仿写深度解析:AI Agent如何复刻你的独特文案风格与节奏 【免费下载链接】FireRed-OpenStoryline FireRed-OpenStoryline is an AI video editing agent that transforms manual editing into intention-driven directing through natural language …

2026/10/1 20:05:24 阅读更多 →

月新闻

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/2 10:36:31 阅读更多 →
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/2 5:26:06 阅读更多 →
黑夜航拍船只数据集训练YOLOV5模型全流程解析

黑夜航拍船只数据集训练YOLOV5模型全流程解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/2 6:09:11 阅读更多 →