练习练习练习
人机猜拳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/8/9 3:13:09 阅读更多 →
11. 类和动态内存分配

11. 类和动态内存分配

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

2026/8/9 3:13:09 阅读更多 →
高职统计与大数据分析专业现状与就业前景

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

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

2026/8/9 3:12:08 阅读更多 →

最新新闻

Wispr Flow Notetaker与Claude集成:基于MCP协议的会议记录自动化实践

Wispr Flow Notetaker与Claude集成:基于MCP协议的会议记录自动化实践

最近在尝试将会议记录自动化整理时,发现了一个痛点:会议录音或笔记的整理工作繁琐耗时,而AI助手虽然强大,却需要手动复制粘贴内容,流程割裂。Wispr Flow推出的Notetaker功能,恰好解决了这个问题&#xff0c…

2026/8/9 6:58:14 阅读更多 →
零命令行部署AI智能体:腾讯云控制台+Docker快速搭建OpenClaw

零命令行部署AI智能体:腾讯云控制台+Docker快速搭建OpenClaw

1. 项目概述:为什么选择腾讯云控制台部署OpenClaw?最近在折腾AI智能体,发现OpenClaw这个开源项目挺有意思。它本质上是一个开源的AI Agent框架,你可以把它理解为一个“AI大脑”的调度中心,能帮你把不同的AI模型&#x…

2026/8/9 6:58:14 阅读更多 →
GPT‑5.6 Sol分数暴涨3倍:不是模型变强,是测试框架不再“失忆”

GPT‑5.6 Sol分数暴涨3倍:不是模型变强,是测试框架不再“失忆”

文章目录 前言1 先把三个分数掰扯清楚1.1 13.3%和38.3%是同一张卷子的两种答法1.2 7.78%是另一个赛道的成绩 2 ARC这题,为啥这么吃“记性”2.1 这不是选择题,是闯关探案2.2 状态断了,等于从头再来 3 官方测试框架的“两层失忆”3.1 第一层&am…

2026/8/9 6:58:14 阅读更多 →
win10搭建hive3开发环境实录

win10搭建hive3开发环境实录

环境准备 需要组件: 组件版本说明JDK8暂时不要选用大于等于JDK9的版本,因为启动虚拟机会发生未知异常MySQL8.x用于管理Hive的元数据Apache Hadoop3.3.0Apache Hive3.1.2Apache Hive src1.2.2因为只有1.x版本的Hive源码提供了.bat启动脚本,有…

2026/8/9 6:58:14 阅读更多 →
基于Claude Code与Docker的Linux环境自动化部署实战

基于Claude Code与Docker的Linux环境自动化部署实战

1. 项目概述:为什么需要全程自动化部署?最近在折腾一个新项目,需要快速搭建一套包含Web服务、数据库和缓存的基础Linux环境。手动操作?太慢了,而且容易出错,换个服务器还得重来一遍。于是,我决定…

2026/8/9 6:58:14 阅读更多 →
电商AI智能体能力评测:MerchantBench基准测试实战指南

电商AI智能体能力评测:MerchantBench基准测试实战指南

如果你正在开发或评估一个电商领域的AI智能体,特别是那种需要处理多轮对话、复杂决策和长流程任务的“长程智能体”,那么你很可能正面临一个核心难题:如何科学、全面地衡量它的真实能力?传统的智能体评测基准,往往聚焦…

2026/8/9 6:57:13 阅读更多 →

日新闻

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁 【免费下载链接】baidupankey 在线查询网盘提取码(维护中 rm repo) 项目地址: https://gitcode.com/gh_mirrors/ba/baidupankey 你是否曾经在深夜寻找一份重要资料&#x…

2026/8/9 0:01:47 阅读更多 →
如何快速生成中国车牌图片:Python开源工具完整指南

如何快速生成中国车牌图片:Python开源工具完整指南

如何快速生成中国车牌图片:Python开源工具完整指南 【免费下载链接】chinese_license_plate_generator 中国车牌生成器 项目地址: https://gitcode.com/gh_mirrors/ch/chinese_license_plate_generator 中国车牌生成器是一个基于Python的开源项目&#xff0c…

2026/8/9 0:01:47 阅读更多 →
收藏!小白程序员轻松入门大模型,从Harness工程开始实践

收藏!小白程序员轻松入门大模型,从Harness工程开始实践

文章强调学习大模型不应只关注模型本身,而应重视模型外的系统搭建,即Harness。提出AgentModelHarness的实用公式,详细介绍Harness的四个层次:持久化层、执行层、控制层和观察与验证层。文章还探讨了上下文工程、工具设计、AGENTS.…

2026/8/9 0:03:48 阅读更多 →

周新闻

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁

5分钟告别提取码焦虑:baidupankey如何智能破解百度网盘资源锁 【免费下载链接】baidupankey 在线查询网盘提取码(维护中 rm repo) 项目地址: https://gitcode.com/gh_mirrors/ba/baidupankey 你是否曾经在深夜寻找一份重要资料&#x…

2026/8/9 0:01:47 阅读更多 →
如何快速生成中国车牌图片:Python开源工具完整指南

如何快速生成中国车牌图片:Python开源工具完整指南

如何快速生成中国车牌图片:Python开源工具完整指南 【免费下载链接】chinese_license_plate_generator 中国车牌生成器 项目地址: https://gitcode.com/gh_mirrors/ch/chinese_license_plate_generator 中国车牌生成器是一个基于Python的开源项目&#xff0c…

2026/8/9 0:01:47 阅读更多 →
收藏!小白程序员轻松入门大模型,从Harness工程开始实践

收藏!小白程序员轻松入门大模型,从Harness工程开始实践

文章强调学习大模型不应只关注模型本身,而应重视模型外的系统搭建,即Harness。提出AgentModelHarness的实用公式,详细介绍Harness的四个层次:持久化层、执行层、控制层和观察与验证层。文章还探讨了上下文工程、工具设计、AGENTS.…

2026/8/9 0:03:48 阅读更多 →

月新闻

免费解锁百度网盘SVIP加速:macOS用户必备的下载提速终极指南

免费解锁百度网盘SVIP加速:macOS用户必备的下载提速终极指南

免费解锁百度网盘SVIP加速:macOS用户必备的下载提速终极指南 【免费下载链接】BaiduNetdiskPlugin-macOS For macOS.百度网盘 破解SVIP、下载速度限制~ 项目地址: https://gitcode.com/gh_mirrors/ba/BaiduNetdiskPlugin-macOS 还在为百度网盘macOS版的龟速下…

2026/8/8 17:02:44 阅读更多 →
终极ncmdump指南:3分钟实现网易云NCM音乐解密与格式转换

终极ncmdump指南:3分钟实现网易云NCM音乐解密与格式转换

终极ncmdump指南:3分钟实现网易云NCM音乐解密与格式转换 【免费下载链接】ncmdump 项目地址: https://gitcode.com/gh_mirrors/ncmd/ncmdump 还在为网易云音乐下载的NCM格式文件无法在其他播放器播放而烦恼吗?ncmdump解密工具帮你轻松解决这个困…

2026/8/9 0:45:04 阅读更多 →
HarmonyOS 应用开发《掌上英语》第81篇: 智能体卡片:为英语学习 App 打造桌面级学习助手

HarmonyOS 应用开发《掌上英语》第81篇: 智能体卡片:为英语学习 App 打造桌面级学习助手

AgentCard 智能体卡片:为英语学习 App 打造桌面级学习助手适用平台:HarmonyOS 7.0 (API 26 Beta)一、引言 HarmonyOS 7.0(API 26 Beta)新增了 AgentCard 智能体卡片能力,这是继 HMAF(鸿蒙智能体框架&#x…

2026/8/8 17:02:44 阅读更多 →