手机站 广告联系

商家热线

代写Polynomial程序、java程序语言作业程序

来源:互联网 作者: 人气: 发布时间:2019-11-25 13:52:55
摘要:代写Polynomial作业、java程序语言作业调试、java实验作业代写、data留学生作业代做 Assignment 4 Question1 Polynomial Design a class named Polynomial Design one constructors: A constructor with one parameter coeicient, which is an int array. Th
代写Polynomial作业、java程序语言作业调试、java实验作业代写、data留学生作业代做
Assignment 4
Question1 Polynomial
Design a class named Polynomial
Design one constructors:
A constructor with one parameter coeicient,
which is an int array. The indexes in the array mean the
exponent and the values in the array mean the coeicient.
For example, if the array is {1, 0, 0, 3, 2}, it
can express the polynomial as 1 + 3X^3 + 2X^4.
Design a toString() method, which can return this polynomial in a specific format, which append all
elements by the way as "exponent:coeicient"
in ascending order of its exponent value, and except the
elements the coeicient
value of which is zero.
For example, if the polynomial is 1 + 3X^3 + 2X^4, the toString() method would return "0:1 3:3
4:2"; if the polynomial is 2X - 3X^2 + 4X^4, the toString() method would return "1:2 2:-3 4:4"
Sample code:
Output:
Design a public method named public Polynomial add(Polynomial polynomial) with an
another Polynomial as a parameter. Aer
executing the method, the original polynomial and the return
value would be the sum of this polynomial + parameter polynomial.
Design a public method named public Polynomial minus(Polynomial polynomial) with an
another Polynomial as a parameter. Aer
executing the method, the original polynomial and the return
value would be the dierence
of this polynomial - parameter polynomial.
int[] p1 = {3, 1, 4, 0, 3};
int[] p2 = {0, 0, 1, 3, 3, 1};
int[] p3 = {4, -2, 1, -4, 0, 3};
int[] p4 = {-2, 3, 1, -1, 0, 4};
int[] p5 = {-2};
Polynomial polynomial1 = new Polynomial(p1);
Polynomial polynomial2 = new Polynomial(p2);
Polynomial polynomial3 = new Polynomial(p3);
Polynomial polynomial4 = new Polynomial(p4);
Polynomial polynomial5 = new Polynomial(p5);
System.out.println(polynomial1);
System.out.println(polynomial2);
System.out.println(polynomial3);
System.out.println(polynomial4);
System.out.println(polynomial5);
0:3 1:1 2:4 4:3
2:1 3:3 4:3 5:1
0:4 1:-2 2:1 3:-4 5:3
0:-2 1:3 2:1 3:-1 5:4
0:-2
Object Name name(String) stationCount(int)
BAOAN "Bao'an" 25
FUTIAN "Futian" 51
LONGGANG "Longgang" 22
LONGHUA "Longhua" 9
LUOHU "Luohu" 23
NANSHAN "Nanshan" 49
(bonus)Design a public method named public Polynomial multiply(Polynomial
polynomial) with an another Polynomial as a parameter. Aer
executing the method, the original
polynomial and the return value would be the product of this polynomial * parameter polynomial.
Design three static methods
respectively with another two Polynomials as parameters. The return value of those three methods is a
new Polynomial that represents the sum, dierence
(le
polynomial - right polymial) and product of those
two parameters, and the original polynmial is not changed.
Question 2 BusLine
It is just a simple exercise for our assignment that the busline in our exercise is only an unidirectional linear
structure, however, the busline in real world would more complex than our exercise.
1. Design a Enum Class named District.
It describes the districts of Shen Zhen city, which includes:
Two private field, name(String) and stationCount(int), which means the name and the total number of
Station of current district. The info data of District are shown in following table.
adding any methods that you think are necessary.
2. Design a Class named Station
Five private data fields
name(String): the name of Station
district(District): the district of Station
latitude(double): the latitude of Station
longitude(double): the longitude of Station
next(Station): it is a Station type, which means the next Station of the current one.
Two constructors
A constructor with no parameter.
A constructor with four parameter as follows
public static Polynomial add(Polynomial p1, Polynomial p2)
public static Polynomial minus(Polynomial p1, Polynomial p2)
(bonus) public static Polynomial multiply(Polynomial p1, Polynomial p2)
getter and setter methods for each private fields. Please design your getter and setter methods in a
standard way.
Hints: What is the next Station:
A method boolean equals(Station s) to judge whether two Stations are identical according to their (all
attributes except next). Here you need to take the case that the parameter s is null into consideration.
A method String toString() as following type:
public Station()
public Station(String name, District district, double latitude, double longitude)
Station s1 = new Station("Taoyuan", District.NANSHAN, 22.5325, 113.92472);
Station s2 = new Station("NanShan", District.NANSHAN, 22.52975, 113.9304333);
s1.setNext(s2);
3. Design a Class named BusLine
It describes an unidirectional linear busline that is composed by many Station.
You can only design those four private data fields, do not add another fields in this class. The fields
includes:
head(Station): the head station of busline, and usually it doesn't store any data except the next Node.
tail(Station): the last station in the busline.
number(String): the number of current busline, such as 81 or 74
size(int): the size of current busline, and the initial value of which is 0, when adding a station, the value
of size would increase by 1.
Two constructors
A constructor with no parameter.
A constructor with one pareameter as follows.
getter and setter methods for each private fields except size.Please design your getter and setter
methods in a standard way.
Add method public void addStation(Station station) : Linked the specified Station to the
end of this list. The value of size would increase by 1.
@Override
public String toString() {
return "Station{" +
"name='" + name + '\'' +
", district=" + district.getName() +
", latitude=" + latitude +
", longitude=" + longitude +
", next=" + next +
'}';
}
public BusLine()
public BusLine(String number)
(bonus)Add method public void addStation(Station station, int index) :Inserts the
specified Station at the specified position (index) in this busline. The value of size would increase by
1.
Add method public boolean isEmpty() : return true if this busline contains no Station,
otherwise return false.
Add method public int size() : return how many Stations in this busline.
Add method public void printStation() : print the name of each Station from the first node
to the tail. Separate names with a space
Add method public Station nearestStation(Station station) : Return the nearest
station of the parameter station in the busline, by calculate the straight-line distance according to
the latitude and longitude.
distance = Math.sqrt( dierence
of latitude^2 + dierence
of longitude ^2)
The nearest station cannot equal the parameter station itself.
Add method public double ratioOfDistrict(District district) : Return the ratio of
total number of all Stations in parameter district in this busline to the total number of Stations in this
district.
Submission of Assignment:
(1) You should submit all the source code files (with an extension “.java”).
(2) You need submit those four java files “.java” Polynomial.java, District.java, Station.java, Busline.java
(3) You should submit all source code directly into your sakai system, do not compress them into one
folder.
(4) No Chinese characters are allowed to appear in your code.
(5) No package included.
(6) The output must strictly follow the description and the sample in this document and the Junit Test, and
you can only get points for each task only when you pass the test case.
(7) The assignment should be submitted before the deadline (Nov. 24th). Late submissions within 24
hours aer
the deadline (even a few minutes) will incur a 50% penalty, meaning that you can only get
50% of the score, which you could get if the assignment was submitted before the latest deadline.
Assignments submitted aer
the latest deadline will not be graded (meaning your will get a zero for the
assignment).
因为专业,所以值得信赖。如有需要,请加QQ:99515681或邮箱:99515681@qq.com 微信:codehelp
责任编辑:
本网网友:我们一起逃跑
评论:人生就像愤怒的小鸟,当你失败时,总有几只猪在笑。。。

百度网友:为了她放弃她
评论:我妈就生了这么一个限量版的我,你看着办吧Q_Q

天猫网友:疲惫了放手了
评论:现在每天吃的是草,可是挤出来的却是青春痘。

淘宝网友:不帶這么玩的
评论:既来之则安之,有福不享是傻子。

其它网友:Sam| 绝情△
评论:每次考完试,我都要安慰自己,没关系,重在参与。

腾讯网友:谁曾朝不保夕
评论:我以为你只是颓废,原来你已经报废了。

猫扑网友:Originalぃ原点
评论:现在告诉你们我结婚的日子喔,它正在海选中呢

网易网友:- 无欲无求/ 
评论:世界上没有绝对幸福圆满的婚姻,幸福只是来自于无限的容忍与互相尊重。

天涯网友:踏歌行人未停
评论:我的兴趣爱好可分为静态和动态两种,静态就是睡觉,动态就是翻身

搜狐网友:迷乱浮生ˉ2c1
评论:人不如己,尊重别人,己不如人,尊重自己。

热门频道推荐

商家热线独家出品

未经授权禁止复制或建立镜像。经贸 之窗 江南

站务及信息报错:1160322105@qq.com
Copyright © http://www.44929.net/ All rights reserved.