Meteorological offices keep records of average monthly rainfalls over a number of cities. The
record for each city consists of the name of the city, the year the data refers to, and a list of
twelve numbers describing respectively the average rainfall in each of the twelve months
of the year. We want to write a Java class system that handles such records. The intended use
includes the setting up of a number of such records, and the printing (on request) of all
available information to the screen. To this end, you need to
1. Create a simple class system meeting the stated requirements. Provide a method that
calculates the average rainfall over a specified number of months for a given city and a
given year.
Hint: You may want to use the decomposition (seen many times in this module) into a
Driver class and another class of your choice, e.g., RainFallRecord, but
~2~
CSE105 Introduction to Programming in Java
remember that the constructor of the latter should carefully validate any data that is to
be assigned to the class attributes. Think about Exception handling.
2. Provide implementations for the following operations (please stick to the given
method signature (i.e. name, parameter list and return value)) for a given year and a
given city:
· double rainfall(String month) searches for the value of the rainfall
in the given month of the year, and city.
· void delete(String month) deletes the rainfall value associated with
the given month, year, and city.
· void insert(String month, double value) inserts the given
rainfall value for the given year, month and city. For simplicity assume that any
value that was there before will be lost.
· void insert(String quarter, double[] value) inserts in the list
the given rainfall values for the given quarter and city. Also, assume that any
value that was there before will be lost.
· String wettest() returns the month with the highest rainfall value over
the given year and city.
Hint: Don’t forget that your code must be robust, i.e. return some answer (e.g., an
error message) even if the particular operation cannot be completed successfully.
3. Define a class Archive, which will be able to store information about a collection of
rainfall records. Provide implementations for the following operations:
a. An appropriate constructor initializing any object of the class type.
b. A method insert to add a rainfall record to the database.
c. A method delete to delete a rainfall record from the database.
d. A method print that prints the whole “database”.
Hint: Remember that combinations “city name + year” should be unique, no two
records in the database should have the same pair of values for the two attributes
mentioned above. Again your code must be robust.
这个是小弟这次的作业。因为要占学分,所以挺纠结的。
依据题目所说是不是需要建立一个database system
希望各位大神能帮帮忙。谢谢啦。

解决方案 »

  1.   

    气象台月平均降雨记录在一些城市。这记录每一个城市都由城的名,年数据指的是,和一串十二个编号描述分别平均降雨量在每12个月的一年。我们想要编写一个Java的阶级体制处理这样的记录。用途包括建立了许多这样的记录,以及印刷(请求)可利用的信息到屏幕上。为此,你需要1。创建一个简单的阶级系统满足规定的要求。提供了一种方法,计算平均降雨量在指定几个月对于一个给定的城市和一个流失。提示:你可能想利用分解(见过多次模块)成一个司机班,另一类你们的选择,例如,RainFallRecord,但是~ 2 ~Java编程CSE105介绍记住,后者的建设者应该仔细的检验数据被指定给类的属性。考虑例外处理。2。提供下列操作实现了(请坚持方法签名(例如名字,参数列表和返回值)和一个年份指定城市:·双降雨(字符串月)寻找价值的降雨量在上个月的一年,和城市。删除·无效(字符串月)删除了有关降雨价值给定的月、年,城市。·无效插入(字符串月,双重价值)插给予的降雨价值为特定的年、月、城市。为了简单假设那是在价值将会丢失。·无效插入(字符串节,双[]价值)插名单给出了降雨价值节和城市。同时,假定任何那是在价值将会丢失。(返回字符串潮湿·月降雨量最高的价值给定年的城市。提示:别忘了,你的代码必须是鲁棒的,即回归(例如一个回答错误信息),即使特定的操作将无法成功完成。3。定义一个类档案,这将可以存储信息的集合降雨记录。为实现对下列操作:构造函数初始化。适当的任何对象类。b。方法降雨记录插入添加一个数据库。c。一个方法删除删除降雨记录从数据库。d。一个方法打印打印整个“数据库”。提示:记住,组合“城市名称+年”应该是独一无二的,没有任何两个记录在数据库中应该有相同的价值观对两个属性上面所提到的。再一次你的代码必须是鲁棒的。
      

  2.   

    cannot connect google's translate server.connection reset.
      

  3.   

    my english is bad bad's;