1350340122 刘光宇 实验二.doc_第1页
1350340122 刘光宇 实验二.doc_第2页
1350340122 刘光宇 实验二.doc_第3页
1350340122 刘光宇 实验二.doc_第4页
1350340122 刘光宇 实验二.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验报告单院(系) 计算机学院 专业 计科(嵌入式)班级 13计科3班 姓名 刘光宇 学号 1350340122 同组人 无 实验室 S4305 组号 日期 2015.9.30 课程 Java程序设计 指导教师 余慧 成绩 实验项目编号 8103200402 实验项目名称 Java简单程序编写 一、 实验目的熟悉并掌握Java中类的定义,类的成员变量和方法的定义。二、 实验环境Windows XP 操作系统 Eclipse三、 实验原理 利用类的关系,其成员变量,和成员方法之间的联系,编写一个房间的构建程序 四、 算法设计【任务一】请完成一个房间的构建程序,房间结构和程序界面如图。具体需求如下表。房间名字室内室外与其连接的过道室内装饰温度通往室外的门房间描述Living Room室内Dining Room,Front YardAn antique carpet/An oak door with a brass knob我站在living room,我看到如下过道:dining room,我看到的装饰是:an antique carpetDining Room室内Living Room, KitchenA crystal chandelier/我站在dining room,我看到如下过道:living room,kitchen,我看到的装饰是:a crystal chandelierKitchen室内Dining Room, Back YardStainless steel appliance/A screen door我站在kitchen,我看到如下过道:dining room,kitchen,我看到的装饰是:stainless steel applianceFront Yard室外Garden, Living Room/不热An oak door with a brass knob我站在front yard,我看到如下过道:back yard,garden。我看到门: An oak door with a brass knob 。Back Yard室外Front Yard, Garden/热A screen door我站在back yard,我看到如下过道:front yard,garden。这里非常热,我看到门: a screen door。Garden室外Front Yard, Back Yard/不热/我站在garden,我看到如下过道:front yard,back yard。五、 主要代码及说明【任务一】import java.util.Scanner;interface Outfacepublic void f1();class OuterClass2private class InnerClass implements OutfaceInnerClass(String s)System.out.println(s);public void f1() System.out.println(;)public Outface doit()return new InnerClass(这是一个接口提示你输入第一个房间为livingroom); class ZiFang /父类protected String name;protected String door;protected String description;protected String aisle = new String2;protected ZiFang()/成员方法 class Room extends ZiFang/子类 protected String decoration; /成员方法 protected Room(String name,String description, String decoration,String door)/参数变量 /zidongshengcheng = name; this.decoration = decoration; this.description = description; protected void print() System.out.println(name is: +name);System.out.println(description is:+description);System.out.println(decoration is:+decoration);System.out.println(door is:+door); class Outside extends ZiFang/子类 protected String temperature; protected Outside(String name,String description,String temperature) = name; this.temperature = temperature; this.description = description; protected void print() System.out.println(name is: +name); System.out.println(description is:+description); System.out.println(temperature is:+temperature); public class Fang public static void main(String args) OuterClass2 out =new OuterClass2(); Outface outin =out.doit(); Scanner sc = new Scanner(System.in); String test ; test = livingroom; while(true) String house = sc.nextLine(); if(house.equals(dining) if(test.equals(livingroom)|test.equals(diningroom)|test.equals(kitchen) Room dining = new Room(dining, now dining, + pass:living,kitchen + ,description:, An antique carpe,null); dining.aisle0 = living room; dining.aisle1 = kitchen; System.out.println(now aisle:); System.out.println(dining.aisle0); System.out.println(dining.aisle1); test = house; System.out.println(now room:+test); else outin.f1(); System.out.println(error!); if(house.equals(livingroom) if(test.equals(dining)|test.equals(livingroom)|test.equals(frontyard) Room livingroom = new Room(livingroom, now living,pass:dining, + description:an antiquecr carpet, An antique carpe,An oak door with a brass knob); livingroom.aisle0 = dining; livingroom.aisle1 = frontyard; System.out.println(now aisle:); System.out.println(livingroom.aisle0); System.out.println(livingroom.aisle1); test = house; System.out.println(now room:+test); else System.out.println(error!); if(house.equals(kitchen) if(test.equals(dining)|test.equals(backyard)|test.equals(kitchen) Room kitchen = new Room(kitchen, now kitchen, + pass:dining,backyard, + description:stainless steel appliance, Stainless steel appliance,A screen door); kitchen.aisle0 = dining; kitchen.aisle1 = kitchen; System.out.println(now aisle:); System.out.println(kitchen.aisle0); System.out.println(kitchen.aisle1); test = house; System.out.println(now room:+test); else System.out.println(error!); if(house.equals(backyard) if(test.equals(kitchen)|test.equals(backyard)|test.equals(garden) Outside backyard = new Outside(backyard, now back yard, + pass:frontyard,garden。 + description, hot); backyard.aisle0 = kitchen; backyard.aisle1 = garden; System.out.println(now aisle:); System.out.println(backyard.aisle0); System.out.println(backyard.aisle1); test = house; System.out.println(now room:+test); else System.out.println(error!); if(house.equals(frontyard) if(test.equals(livingroom)|test.equals(frontyard)|test.equals(garden) Outside frontyard = new Outside(frontyard, now frontyard, + pass:livingroom,garden。 + door: fff , Nothot); frontyard.aisle0 = livingroom; frontyard.aisle1 = garden; System.out.println(now aisle:); System.out.println(frontyard.aisle0); System.out.println(frontyard.aisle1); test = house; System.out.println(now room:+test); else System.out.println(error!); if(house.equals(garden) if(test.equals(frontyard)|test.equals(garden)|test.equals(backyard) Outside garden = new Outside(garden, now garden, + pass:frontyard,backyard , :Nothot); garden.aisle0 = frontyard; gard

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论