Instruction You will be developing a TicketMaster-like application, used to view
ID: 3813442 • Letter: I
Question
Instruction
You will be developing a TicketMaster-like application, used to view and purchase tickets to upcoming shows. The idea is that customers can log into the site to purchase tickets. Administrative users will be able to create and edit concert information and see a list of purchases that have been made.
Using Rails built-in scaffolding, create the models as described on the model diagram.
Create a “Register” link in your navigation area. This link should allow an individual to register on the website. Ensure you have set up the User model as described to support the authlogic functionality.
Ensure that registered users can log in and log out of your web application.
Logged-in users should have the ability to update their profiles (username, email, and password.)
Update the navigation of your layout to meet the following criteria: Logged-out users should see two links: “Register” and “Login”, Logged-in users should see two links: "Edit Profile" and “Logout”
Install and require the cancancan gem in your application.
Using Rails built-in scaffolding, create the files for the “Role” class, as described on the model diagram attached to this Assignment.
Seed two new roles: Customer and Admin
Create the HABTM association between the User and Role models, and ensure you create a join table in your database to store the relationships.
Use the check_box_tag form helper to allow the selection of roles on the Create or Edit User form pages.
IF A USER IS BEING CREATED: his/her default role should be “Customer” only and the check_box_tag area should be hidden
IF A CUSTOMER IS LOGGED-IN: s/he should not see the check_box_tag area; Customers should not be able to assign their own roles
IF AN ADMIN IS LOGGED-IN: s/he MAY update the roles of the user being edited. The Admin should be able to select Customer or Admin OR both.
Using Rails built-in scaffolding, create the files for the “Concert” and "Venue" class, as described on the model diagram attached to this Assignment.
You will need to create a foreign key to support this relationship.
Seed 3 Concerts and 2 Venues in your database. Assign each Concert to a Venue.
Question
Create abilities for the Concert model according to the following logic: Customers can index and view (show) all Concert objects, Admins can manage (index, show, create, update, destroy) all Concert objects
Explanation / Answer
Raw
SavingsAccountTester.java
public class SavingsAccount { private double balance; private double interest; public SavingsAccount() { balance = 0; interest = 0; } public SavingsAccount(double initialBalance, double initialInterest) { balance = initialBalance; interest = initialInterest; } public void deposit(double amount) { balance = balance + amount; } public void withdraw(double amount) { balance = balance - amount; } public void addInterest() { balance = balance + balance * interest; } public double getBalance() { return balance; } }