求一个求生之路applicationn Comp...

.编写一个完整的Java Application 程序。包含接口ShapeArea,MyRecta具体要求如下:
⑴接口ShapeArea:
getArea():求一个形状的面积
getPerimeter ():求一个形状的周长 ⑵类 MyRectangle:
实现ShapeArea接口,并有以下属性和方法: ① 属性 width:
double类型,表示矩形的长 height:
double类型,表示矩形的高 ② 方法 MyRectangle(double
h):构造函数
toString()方法 :输出矩形的描述信息,如“width=1.0,height=2.0, perimeter=6.0, area=2.0” ⑶类MyTriangle:
实现ShapeArea接口,并有以下属性和方法: ① 属性 x,y,z: double型,表示三角形的三条边 s: 周长的1/2(注:求三角形面积公式为 ,s=(x+y+z)/2 ,开方可用Math.sqrt(double)方法) ② 方法 MyTriangle(double
z):构造函数,给三条边和s赋初值。 toString():输出矩形的描述信息,如“three sides:3.0,4.0,5.0,perimeter=12.0,area=6.0” ⑷Test类作为主类要完成测试功能 ① 生成MyRectangle对象 ② 调用对象的toString方法,输出对象的描述信息
血刃迷茫t84
以下每一个类和每一个接口都各自存成一个和类名或接口名一致的文件,然后编译后运行Test类。
声明:绝对原创,但是由于时间禁,未经编译。
public interface ShapeArea{
public double getArea();
public double getPerimeter(); }
public class MyRectangle implments ShapeArea{
public MyRectangle(double w, double h){
this.width =
this.height =
public double getArea(){
return w *
public double getPerimeter(){
return 2 * (w + h);
public String toString(){
return "width=" + width + ",height=" + height +
",perimeter=" + getPerimeter() +
", area=" + getArea();
public void setWidth(double width){
this.width =
public double getWidth(){
public void setHeight(double height){
this.height =
public double getHeight(){
public class MyTriangle implments ShapeArea{
public MyTriangle(double x, double y, double z){
public double getArea(){
return 这里是三角形面积的计算公式,我不会写 ;
public double getPerimeter(){
return x + y +
public String toString(){
return "three sides:" + x + "," + y + "," + z +
",perimeter=" + getPerimeter() +
", area=" + getArea();
public void setX(double x){
public double getX(){
public void setY(double y){
public double getY(){
public void setZ(double z){
public double getZ(){
public class Test{
public static void main(String[] args){
ShapeArea sa = new MyRectangle(2.0,3.0);
System.out.println(sa.toString());
为您推荐:
扫描下载二维码Java Code Example org.restlet.ext.jaxrs.JaxRsApplication
Java Code Examples for org.restlet.ext.jaxrs.JaxRsApplication
The following are top voted examples for showing how to use
org.restlet.ext.jaxrs.JaxRsApplication. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
+ Save this class to your library
public void testSimple()
throws Exception
Component comp = new Component();
Server server = comp.getServers().add( Protocol.HTTP, 8182 );
// create JAX-RS runtime environment
JaxRsApplication application = new JaxRsApplication( comp.getContext() );
// plexus goes here
application.setObjectFactory( getPlexusObjectFactory() );
// attach ApplicationConfig
application.add( getApplication() );
// Attach the application to the component and start it
comp.getDefaultHost().attach( application );
comp.start();
System.out.println( &Server started on port & + server.getPort() );
System.out.println( &Press key to stop server& );
System.in.read();
System.out.println( &Stopping server& );
comp.stop();
System.out.println( &Server stopped& );
* Creates a
JaxRsApplication}. Not needed for the test case
* developer by default.
* @param appConfig
the applicationConfi to use
* @param challengeScheme
the challengeScheme to use, if a RoleChecker is given.
* @param roleChecker
the RoleChecer to use.
protected JaxRsApplication createApplication(Application appConfig,
ChallengeScheme challengeScheme, RoleChecker roleChecker) {
final JaxRsApplication application = new JaxRsApplication(new Context());
if (roleChecker != null) {
application.setRoleChecker(roleChecker);
final Guard guard = createGuard(application.getContext(),
challengeScheme);
application.setGuard(guard);
application.add(appConfig);
public static void main(String[] args) throws Exception {
// create Component (as ever for Restlet)
final Component comp = new Component();
final Server server = comp.getServers().add(Protocol.HTTP, 80);
// create JAX-RS runtime environment
final JaxRsApplication application = new JaxRsApplication(comp
.getContext().createChildContext());
// create a Guard
final Guard guard = new Guard(application.getContext(),
ChallengeScheme.HTTP_BASIC, &JAX-RS example&);
// set valid users and thier passwords.
guard.getSecrets().put(&admin&, &adminPW&.toCharArray());
guard.getSecrets().put(&alice&, &alicesSecret&.toCharArray());
guard.getSecrets().put(&bob&, &bobsSecret&.toCharArray());
// create an RoleChecker (see above)
final ExampleRoleChecker roleChecker = new ExampleRoleChecker();
// attach Guard and RoleChecker
application.setAuthentication(guard, roleChecker);
// attach ApplicationConfig
application.add(new ExampleApplication());
// Attach the application to the component and start it
comp.getDefaultHost().attach(application);
comp.start();
System.out.println(&Server started on port & + server.getPort());
System.out.println(&Press key to stop server&);
System.in.read();
System.out.println(&Stopping server&);
comp.stop();
System.out.println(&Server stopped&);
public static void main(String[] args) throws Exception {
// create Component (as ever for Restlet)
final Component comp = new Component();
final Server server = comp.getServers().add(Protocol.HTTP, 80);
// create JAX-RS runtime environment
final JaxRsApplication application = new JaxRsApplication(comp
.getContext().createChildContext());
// attach ApplicationConfig
application.add(new ExampleApplication());
// Attach the application to the component and start it
comp.getDefaultHost().attach(application);
comp.start();
System.out.println(&Server started on port & + server.getPort());
System.out.println(&Press key to stop server&);
System.in.read();
System.out.println(&Stopping server&);
comp.stop();
System.out.println(&Server stopped&);
@Path(&/unload&)
public Json unload()
JaxRsApplication app = (JaxRsApplication)StartUp.server.getDefaultHost().getApplication();
StartUp.server.getDefaultHost().detach(StartUp.jsonpFilter);
StartUp.server.getDefaultHost().detach(app);
return ok();
catch (Throwable t)
t.printStackTrace(System.err);
return ko(t.toString());
public static Restlet createRestServicesApp()
final JaxRsApplication app = new JaxRsApplication(server.getContext().createChildContext());
EncoderService encoderService = new EncoderService();
encoderService.setEnabled(true);
//app.setEncoderService(encoderService);
app.getLogger().setLevel(LOGGING_LEVEL);
Vector&File& v = new Vector&File&();
v.add(new File(new File(config.at(&workingDir&).asString()), &hotdeploy&));
AdaptiveClassLoader loader = new AdaptiveClassLoader(v, true);
MainRestApplication main = new MainRestApplication(loader);
main.configure(OWL.individual(config.at(&mainApplication&).asString()));
app.add(main);
catch (Exception ex)
throw new RuntimeException(ex);
// Set filters.
HttpMethodOverrideFilter methodFilter = new HttpMethodOverrideFilter(app.getContext());
methodFilter.setNext(app);
jsonpFilter = new PaddedJSONFilter(app.getContext());
jsonpFilter.setNext(methodFilter);
TrafficMonitor trafficMonitor = new TrafficMonitor(app.getContext());
trafficMonitor.setNext(jsonpFilter);
requestScopeFilter = new RequestScopeFilter();
requestScopeFilter.setNext(jsonpFilter);
encoder = new Encoder(app.getContext(),
encoderService);
encoder.setNext(requestScopeFilter);
//set the form param fix as the last filter in the chain.
Filter formParamFix = new FormParamAdditionalDecodeFilter(app.getContext());
formParamFix.setNext(encoder);
return formParamF您的举报已经提交成功,我们将尽快处理,谢谢!
把楼上的优化一下:
#include "stdio.h"
#include "math.h"
void main()
{ int i,j,k;
...
#include &iostream&
int i,input=0,count=0,sum=0;
很简单啊,直接一个for循环就可以啦。
#include&iostream&
int main()
要想自动加载,大约有这么几种方法:
1.用命令或者菜单预加载。命令appload(菜单[工具/tools]&&[自动加载应用程序/automatic load ...
要看你的机子的配置了,魔兽的要求挺高的。你下载是应该看清楚的。当然也应该打补丁的。
大家还关注

参考资料

 

随机推荐