المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حل واجب M257 على 0544321455 - [email protected] > M257 > 000966544321455



أسواق
30-03-2013, 10:50 PM
M257, Putting to Work
Spring April 30, 2013
Question 1.
This assignment is an exercise in fundamental concepts such as: classes, constructors, methods, composition, interfaces, basic control structure, and ArrayLists. This question includes two parts, each of which is simple if done according to the specifications given in the exercise.
Q1.1: Write a program according to the following specifications:
(a) Develop an interface HumanInterface that includes four public methods: String get(), String gee(), void set(String s),and void see(double d). When these methods are implemented, they should set or return the or age of their .
(b) Develop a public abstract class Human to the following specifications:
The class implements HumanInterface.
The class has two private instance variables: String , and double age.
The class has a two-argument constructor to set its instance variables to given values.
The class overrides the ’s toString()method in order to return a string representation of a Human similar to format given below:
Ali, 16 years old
The class implements any additional necessary methods, if applicable.
(c) Develop a public class Player to the following specifications:
The class is a subclass of Human.
The class has one private instance variable: int number.
The class has a three-argument constructor to set its instance variables to given values. This constructor should invoke the superclass constructor.
The class has setter and getter methods for number.
The class overrides the ’s equals method in order to compare the s of two s of the type Human and return true if the states of the two s are identical, and false otherwise.
The class overrides the toString()method in order to return a string representation of a Player similar to format given below:
Ali, 16 years old, Number: 3
the toString()method should invoke the parent’s toString()method to get the first part of the returned value.
(d) Develop a public class Team, that represents a list of players in a team, to the following specifications:
(21 marks)
The class has four private instance variables:
_ String , which represents the of the team.
_ int count, which indicates the current number of players enrolled in the team.
_ int size, which indicates the maximum number of players that can be enrolled in the
team. This number will be obtained later from the user.
_ ArrayList players, which will represent the collection of players in the
team.
The class has a zero-argument constructor that does the following whenever creating a new team instance:
_ Asks the user about the team , and sets accordingly.
_ Asks the user about the maximum number of players, and sets size accordingly.
_ Declares the players ArrayList with an initial capacity equal to size.
_ Asks the user whether s/he wants to enter the information of all team’s players. If the user’s answer is yes, then the system should add all players using the addPlayers() method which will be described shortly.
Note: You must either use Scanner or BufferedReader to get users’ input.
The class has getter methods for , size, and count.
The class has a public method boolean addPlayer(Player pl) which is used to add one player to the team if the team is not full. The method should add the player pl to the players, increment count, display a message that the player is added, and finally return true. If the team is full, an appropriate message should be displayed, and the method should return false.
Hint: to check whether the team is full or not, use count and size.
The class has a static method Player createPlayer(). The method should ask the user for a player’s , age, and number, and then return an instance of Player initialized to the obtained values. You must either use Scanner or BufferedReader to get users’ input.
The class has a public method void addPlayers() which is used to add the remaining
players to the team. For example, if the team’s size is 12 and it already includes 5 players (i.e. count = 5), then this method should add 7 more players to the team using both addPlayer and createPlayer methods. Note that the method should only add players if the team is not full, otherwise it should display an error message.
The class overrides the toString()method in order to return a string representation of a Team , showing the team’s , number of players, and list of all players who joined the team. For example: Team Egypt has 2 player(s)
1- Ali, 18.0 yrs old, Number: 1.
2- Ahmed, 19.0 yrs old, Number: 2.
Q1.2: Develop a public class Main to test the classes in Q1.1. This class will only have the main method that should:
create a Team instance with any appropriate state,
add one player using the team’s addPlayer method. Hint: use the static method createPlayer to create a player instance.
Display the teams information. A sample run is shown in the figure below.
Important: You must include screenshots for Q1.1 and Q1.2 with appropriate evidence that the code was written by you. Up to 8 marks will be deducted from your mark if you don’t do so.
Q1.3: Essay question related to Q1.1 and Q1.2: (6 marks)
a. List two differences between Human and HumanInteface.
b. What is the appropriate term to describe that Team class contains s of Player class?
Briefly explain how that is different from Inheritance.
Question 2.
This assignment is an exercise on using building GUI interfaces, writing event driven programs, along with using flow control structures, and JOptionPane classes.
Q2.1: In this question, you are required to build a GUI interface to replace the ual interface you have developed in Question 1. You need to develop a class MainGUI that extends the JFrame class. The design of MainGUI is illustrated in the figure below. You also need to replace all ual-d input or output in the classes of Q1.2 with appropriate methods from the JOptionPane class; for example, replace System.out.println() with JOptionPane.showMessageDialogue().
When writing the code, you should create another package for the classes of this question and copy all classes and the interface from Q1.2 into this package. This means your package will include the following classes and interface: HumanInteface, Human, Player, Team, and MainGUI.
The MainGUI class should have a main method to instantiate the class. The operation of MainGUI is described as follows: (40 marks)
The class should include a declaration of a reference variable of the type Team.
When the user clicks the button “Create Team” for the first time, an instance of Team is
instantiated, and the three top labels are updated with the team’s , count, and maximum size.
If the user clicks the “Create Team” button again, a message should appear to inform the user that the team has been already created, and no further Team instances are instantiated.
When either the “Add one player” or “Add remaining players” buttons is clicked, the program should check first whether a team instance has already been instantiated. If it has not, then a message asking the user to create a team first is displayer. If a team instance has been created, then the appropriate method of the team instance should be invoked. That is, when a user clicks “Add player” button, the method addPlayer()should be invoked. On the other hand, when the button “Add remaining players” is clicked, your program should check first whether the team is full or not. If the team is full, an error message is displayed, otherwise addPlayers()is invoked.
When the user clicks “Exit” button, the program should terminate.
The labels at the top of the GUI should always be kept up to date after any change to the team.
The JArea should always include an up-to-date list of all players of the created team.
Important: You must include screenshots for Q2.1 and Q2.2 with appropriate evidence that the code was written by you. Up to 8 marks will be deducted from your mark if you don’t do so. A panel that includes four buttons. The panel’s layout is GridLayout.
JFrame attributes:
- Title: Team manager
- Layout: BorderLayout
- Close button terminates program
A JPanel that includes
3 JLabels to display a
summary of the team’s
info. The panel’s layout
is GridLayout.
A JArea
that displays
the details of
the team.
A drawing that represents a simple
team’s logo! Each student must
make his/her own design.
Q2.2: Essay question related to Q2.1 and Q2.2:
a. Why is it better to separate the source of the events (e.g. buttons) from the place where the event is dealt with (i.e. event handlers)?
b. Which technique have you used for handling events in your code: implementing listener interfaces or extending adapter classes? Why?
Question 3. [10 marks]
Using the AOU’s eLibrary facility and the internet, locate the two papers indicated below (note the dates), and answer the following in your own words:
(i) What is the original security model that provides? Briefly discuss this model.
(ii) What is meant by the following terms: “bytecode verifier” and “code signing”?
(iii) What is exploit kits? Give 3 examples.
Source:
L. Gong, “ Security: Present and Near Future”, IEEE Micro, May1997, pp.14-19.
L. Garber,“Have 's Security Issues Gotten out of Hand?”, IEEE Computer, Dec. 2012, pp. 18-21.