高分跪求java编程程序 急求!! 在线等!明天就要交!!好的话追加分!!

内容是创造一个宠物狗 快乐能量如果0就死亡, 可以喂食,睡觉恢复。 大概300行左右
1. Electronic Dog
Write a program to model dog adoption. The program has 3 elements:
 Time
 Happiness
 Energy
You can have activities with it:
Play 2 +2 -1
Conditions:
a) The total time to play this program is set by the user (e.g. >=24 hours). If there is no accident, the user adopts the dog forever when the program stops
b) The duration of feeding your dog is 3 hours
c) If the happiness level is 0, the dog leaves
d) If the energy level is 0, the dog dies
e) If the dog does not sleep within 10 hours, it leaves

电子狗类:

public class 电子狗 {
public int ghostpill=1;
public int grade;
public int happy;
public int talent;
public int hungry;
public int clear;
public int health;
//2个构造器
public 电子狗(){
grade=0;
happy=50;
talent=0;
hungry=50;
clear=50;
health=100;
}
public 电子狗(int g,int ha,int t,int hu,int c,int he){
grade=g;
happy=ha;
talent=t;
hungry=hu;
clear=c;
health=he;
}
public void printHead(){
System.out.println("欢迎来到电子狗窝~O(∩_∩)O~");
System.out.println("狗狗昵称:春狗");
System.out.println("主人:春熊");
System.out.println("主人的邮箱:conmajia@163.com");
}
public void printState(){
System.out.println("等级:"+grade);
System.out.println("快乐:"+happy);
System.out.println("智商:"+talent);
System.out.println("饥饿:"+hungry);
System.out.println("清洁:"+clear);
System.out.println("健康:"+health);
}
public void play(){
happy+=5;
talent+=2;
hungry-=5;
clear-=2;
health+=5;
grade+=1;
System.out.println("主人~我今天玩得好开心丫~");
System.out.println("(你的狗狗:等级上升1点、快乐上升5点、智商上升2点、饥饿下降5点、清洁下降2点、健康上升5点)");
}
public void learn(){
happy+=2;
talent+=5;
hungry-=2;
grade+=5;
System.out.println("主人~我今晚要挑灯夜战,横扫浙大图书馆的所有Java书!");
System.out.println("(你的狗狗:等级上升5点、快乐上升2点、智商上升5点、饥饿下降2点)");
}
public void wash(){
happy+=5;
clear+=15;
health+=5;
System.out.println("主人~玩水真爽~真希望天天过泼水节~O(∩_∩)O哈哈~!");
System.out.println("(你的狗狗:快乐上升5点、清洁上升15点、健康上升5点)");
}
public void inject(){
happy-=10;
health+=20;
System.out.println("555~~~~主人~打针好痛~~~~~~~再也不要来医院了!");
System.out.println("(你的狗狗:快乐下降10点、健康上升20点)");
}
public void pill(){
happy-=5;
health+=15;
System.out.println("主人~这药好苦~下次记得买水果口味的脑黄金~(*^__^*)嘻嘻……");
System.out.println("(你的狗狗:快乐下降5点、健康上升15点)");
}
public void ghost(){
if(ghostpill>0){
happy+=1000;
hungry+=1000;
health+=1000;
clear+=1000;
ghostpill--;
System.out.println("主人!我复活啦!哇哈哈!想死我了吧!呼呼(~ o ~)~zZ");
System.out.println("(你的狗狗:快乐上升1000点、饥饿上升1000点、清洁上升1000点、健康上升1000点)");
}
else{
System.out.println("很遗憾~你的还魂丹已经用完了~");
}
}
public void shopping(){
happy+=20;
hungry-=10;
clear-=5;
System.out.println("沃尔玛的东西真多~眼都看花了我~~~~~~呼呼(~ o ~)~zZ");
System.out.println("(你的狗狗:快乐上升20点、饥饿下降10点、清洁下降5点)");
}
}

StartPet类:

import java.util.*;
public class StartPet {
static int choice;
public static void main(String[] args){
电子狗 myPet=new 电子狗();
myPet.printHead();
while(true)
{
printChoice();
doChoice(choice,myPet);
}
}
static void printChoice(){
Scanner in=new Scanner(System.in);
System.out.println("--------------------------------------------------");
System.out.println("请选择:");
// System.out.println("1.状态");
// System.out.println("2.玩耍");
// System.out.println("3.洗澡");
// System.out.println("4.打针");
// System.out.println("5.吃药");
// System.out.println("6.购物");
System.out.println("1.状态 2.玩耍 3.洗澡 4.打针 5.吃药 6.购物 7.学习 8.还魂丹");
System.out.println("--------------------------------------------------");
choice=in.nextInt();
}
static void doChoice(int choice,电子狗 myPet){
switch(choice){
case 1:
myPet.printState();
break;
case 2:
myPet.play();
break;
case 3:
myPet.wash();
break;
case 4:
myPet.inject();
break;
case 5:
myPet.pill();
break;
case 6:
myPet.shopping();
break;
case 7:
myPet.learn();
break;
case 8:
myPet.ghost();
break;
default:
break;
}
}
}追问

大哥,好多红线啊。。。

运行后出现:
java.lang.NoSuchMethodError: main
Exception in thread "main"

温馨提示:内容为网友见解,仅供参考
第1个回答  2011-05-28
一天就是现写也不太来得及啊……追问

能写50行也可以,我先看看

相似回答