Course web page: Introduction to Computer Science for non-majors II James Tam Return to the course web page

CPSC 219: Mini-Assignment #2

Due Monday Feb 2, at 4 PM

New Concepts to be applied for the assignment

Description

Your program must consist of three classes (as described below). Aside from the 'main()' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course). Your program must consist of three classes (as described below). If you do implement other static methods then you will receive few, if any, marks for features listed below.

Description

  • Defines a class 'Cat' (5 marks)
 
  •  Attributes: name (String), and favoriteFood (String) (2 marks)
 
  • Methods:
     
  • A no argument constructor that sets the name and favoriteFood attributes to obvious default starting values (e.g., "no name" for the name and "I hate everything you give me >.<" for the food) (2 marks)
  • A 'makeSound()' method that displays "meow" onscreen when the method is called (1 mark)
     
  • Defines a class 'Dog' (4 marks)
 
  •  Attributes: name (String) and favoriteFoods (a String array with two elements) (2 marks)
 
  • Methods:
     
  • A no argument constructor that sets the name and food attribute to obvious default starting values (e.g., "no name" for the name and ["dog food", "your food"] for the foods) (2 marks)
     
  • Defines the 'Driver' class. The 'main()' method will contain the following instructions (11 marks)
 
  • Create instances of a dog and cat (2 marks)
  • Displays the name and favorite food attributes of the dog onscreen, the default values should appear (2 marks)
  • Displays the name and favorite food attributes of the cat onscreen, the default values should appear (2 marks)
  • Sets the name of the cat to 'Sylvester' and favorite food to 'Catnip' (2 marks)
  • Displays the name and favorite food attributes of the cat onscreen, the new values should appear (2 marks)
  • Calls Sylvester's 'makeSound()' method (1 mark)

Submitting your work:

  1. Assignments (source code/'dot-java' file) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Marking key

Marks earned 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Grade point 4.0 3.8 3.6 3.4 3.2 3.0 2.8 2.6 2.4 2.2 2.0 1.8 1.6 1.4 1.2 1.0 0.8 0.6 0.4 0.2 0.0

External libraries that can be used (unless otherwise you can not assume that you can use the library).

  1. You cannot use methods other than the ones for output: printf(), print(), println().