首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导Java语言程序、讲解program程序设计、Java编程调试 辅导留学生 Statistics统计、回归、迭代|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
Assignment 4
Important
Deadline: 10:00 PM, May 30, 2021
You can submit your solution to the OJ system for multiple times. But note that too many
submissions many affect your final score!
You can discuss with your classmates about the assignment but do NOT copy others’
solutions. The OJ system can detect the duplication. If confirmed that there is a plagiarism,
both parties will get 0 mark for this assignment as a penalty.
Note that this time you may need to change the judging environment according to
problem's requirement!
Problems
Problem A - Fraction [Easy, 25 marks, Java (JUnit5)]
Problem B - Triangle [Easy, 25 marks, Java (JUnit5)]
Problem C - Hotel [medium, 50 marks, Java (JUnit5)]
Problem A - Fraction
Description
Design a class Fraction to represent fractions. This class needs to implement the four
operations(plus, subtract, multiply and divide) on fractions and find the reciprocal of a fraction.
Submission
Please select Java(JUnit5) as the judge environment when submitting.
You need submit Fraction.java .
Requirements
Do not modify or remove any methods or fields that have been already defined.
You can add methods or fields that you think are necessary.
This class uses two variables of type int to represent the numerator and denominator
respectively (Both of these variables should be non-negative), and one variable of type
boolean to represent whether the fraction is positive or negative (the value should be true
when the fraction is 0).
Simplify the result after each operation or set the value of the numerator or denominator.
For example, if you get "2/4", you need to convert it to "1/2".
When the numerator is greater than the denominator, there is no need to present the
integer part. For example, "31/30" is a correct output.
For integers, when calling toString() only the numerator should be displayed, like "0", "3" or
"-10".
Sample
You can use FractionTest.java to test. The output of it would be
You are supported to add some test cases yourself to test other situations.
Problem B - Triangle
Description
You need to implement a class to represent triangles. Implement functions to determine if a
triangle is a special triangle (right triangle, isosceles triangle, equilateral triangle) and to determine
if this triangle is similar or congruent to another triangle.
Submission
Please select Java(JUnit5) as the judge environment when submitting.
You need submit Triangle.java .
Requirements
Do not modify or remove any methods or fields that have been already defined.
You can add methods or fields that you think are necessary.
You need a constructor with no arguments to create a triangle with all three sides of length
1. You also need a constructor with three arguments representing the length of three side in
the triangle. If these three arguments do not enclose the triangle (e.g. 1, 1, 2), then a triangle
with all three side lengths of 1 will also be created.
Sample
You can use TriangleTest.java to test. The output of it would be
You are supported to add some test cases yourself to test other situations.
3/4
0.75
4/3
1
1
6.0
12
true
true
Problem C - Hotel
Description
As you know that for some hotels, they have different type of rooms. Everyday, several rooms
have been checked in and several rooms have been checked out, and during the process the
hotel has incomes accordingly. Then you are asked to help a hotel owner to design a room
management system. There are two types of rooms: Ordinary Room and Luxury Room.
Submission
Please select Java(JUnit5) as the judge environment when submitting.
You need submit Hotel.java , ConcreteHotel.java , Day.java , Room.java ,
LuxuryRoom.java and OrdinaryRoom.java .
Do not modify or remove any methods or fields that have been already defined in these two
files Hotel.java and Room.java .
Requirements
Your task is to design following classes:
1. Room and Hotel
Do not modify or remove any methods or fields that have been already defined.
You can add methods or fields that you think are necessary.
You can see the job for each function in Hotel.java by looking at Hotel.html .
2. LuxuryRoom and OrdinaryRoom. Those are the subclasses of the class Room.
LuxuryRoom: adding a private data field named addBed(boolean) with an initial value
false.
OrdinaryRoom: adding a private data field name breakfastCount(int) with an initial
value 0.
toString method: Override toString method in each subclasses. Here the return format
must strictly follow the requirement.
checkOut and checkIn method: Override the abstract method in each subclasses.
You can add other methods or attributes that you think are necessary.
3. Day. We use this class to represent the days of the week. There are three required data
fields to hold the required information
name: private, String. Name of this day.
rate: private, double. The rate of price in this day.
gift: private, String. A gift from the hotel on this day.
Information for this class:
name rate gift
MONDAY MON 0.8 Fruits
TUESDAY TUE 0.75 Drinks
WEDNESDAY WED 0.71 GYM CARD
THURSDAY THU 0.68 Fruits
FRIDAY FRI 1 GYM CARD
SATURDAY SAT 1 HOT SPRINGS
SUNDAY SUN 0.95 SWIMMING
When you call the toString method you will get return value like "Day{name='MON',
rate=0.8, gift='Fruits'}".
4. ConcreteHotel. It is a concrete class of the interface Hotel, in which you need to implement
all the abstract methods that are declared in the interface Hotel. In concrete Hotel, the
following important data field must be defined. Beyond that, you can define any attributes
that you think are important.
rooms: It is a List
type, which contains all rooms, including two different types,
in concrete hotel.
5. Other import parameters:
However, there are several initial parameters needs to be mentioned to you, where defining
those parameters depends on your design.
The price of breakfast for one person in Ordinary Room is 180.
The price of adding a bed in Luxury Room is 250.
The initial basic price of Luxury Room is 1200 per night (the breakfast is included).
The initial basic price of Ordinary Room is 500 per night (adding a bed is not allowed).
The calculation of total price for one room per night is
For Luxury Room:
Basic price of Luxury Room * the rate of price in current day + the price of added
beds (if need)
For ordinary Room:
Basic price of Ordinary Room * the rate of price in current day + the price of
breakfast * the number of breakfast.
The initial value of day is MONDAY
Sample
You can use HotelTest.java to test. The output of it would be
private List
rooms = new ArrayList<>();
L R1 false
O R2 0
L R3 false
You are supported to add some test cases yourself to test other situations.
L R4 false
L R5 false
L R6 false
L R7 false
O R8 0
O R9 0
O R10 0
O R11 0
O R12 0
1200 500
Day{name='MON', rate=0.8, gift='Fruits'}
Day{name='TUE', rate=0.75, gift='Drinks'}
Day{name='WED', rate=0.71, gift='GYM CARD'}
Day{name='THU', rate=0.68, gift='Fruits'}
Day{name='FRI', rate=1.0, gift='GYM CARD'}
Day{name='SAT', rate=1.0, gift='HOT SPRINGS'}
Day{name='SUN', rate=0.95, gift='SWIMMING'}
R1 R2 R3 R8
R3
3330
Day{name='TUE', rate=0.75, gift='Drinks'}
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!